blob: 881cc78848dde3adec47083d41b198e6386b4d98 [file] [log] [blame]
Denys Vlasenko007ce9f2017-08-13 02:59:00 +02001(
2
Denys Vlasenko81f962f2017-08-11 02:05:21 +02003set -- -q -w e -r -t -y
4echo "*** no OPTIND, optstring:'w:et' args:$*"
5var=QWERTY
6OPTARG=ASDFGH
7while getopts "w:et" var; do
8 echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
Denys Vlasenko9a7d0a02017-08-11 02:37:48 +02009 OPTARG=ASDFGH
Denys Vlasenko81f962f2017-08-11 02:05:21 +020010done
11echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
12
13set -- -w 1 -w2 -w -e -e -t -t
14echo "*** OPTIND=0, optstring:'w:et' args:$*"
15OPTIND=0
16while getopts "w:et" var; do
17 echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
Denys Vlasenko9a7d0a02017-08-11 02:37:48 +020018 OPTARG=ASDFGH
Denys Vlasenko81f962f2017-08-11 02:05:21 +020019done
20echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
Denys Vlasenko007ce9f2017-08-13 02:59:00 +020021
22) 2>&1 \
23| sed -e 's/ unrecognized option: / invalid option -- /' \
24 -e 's/ illegal option -- / invalid option -- /' \