busybox/shell/ash_test/ash-getopts/getopt_optarg.tests
Denys Vlasenko 9a7d0a0191 shell: add OPTARG poisoning to getopt_optarg.tests
ash fails this!

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-11 02:37:48 +02:00

19 lines
499 B
Plaintext
Executable File

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'"