summaryrefslogtreecommitdiff
path: root/shell/hush_test/hush-getopts/getopt_optarg.tests
blob: 881cc78848dde3adec47083d41b198e6386b4d98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(

set -- -q -w e -r -t -y
echo "*** no OPTIND, optstring:'w:et' args:$*"
var=QWERTY
OPTARG=ASDFGH
while getopts "w:et" var; do
	echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
	OPTARG=ASDFGH
done
echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"

set -- -w 1 -w2 -w -e -e -t -t
echo "*** OPTIND=0, optstring:'w:et' args:$*"
OPTIND=0
while getopts "w:et" var; do
	echo "var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"
	OPTARG=ASDFGH
done
echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"

) 2>&1 \
| sed	-e 's/ unrecognized option: / invalid option -- /' \
	-e 's/ illegal option -- / invalid option -- /' \