aboutsummaryrefslogtreecommitdiff
path: root/shell/ash_test/ash-getopts/getopt_optarg.tests
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-08-11 02:05:21 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-08-11 02:05:21 +0200
commit81f962f3df0d7194b7a52c6f83259727759094c4 (patch)
tree906d5d55118f0a7c96579c7d12c62b3a14311a7a /shell/ash_test/ash-getopts/getopt_optarg.tests
parent74d40589288890fffea437ed2f38ad1f2dc740e5 (diff)
downloadbusybox-81f962f3df0d7194b7a52c6f83259727759094c4.tar.gz
hush: teach getopts to set/unset OPTARG
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/ash_test/ash-getopts/getopt_optarg.tests')
-rwxr-xr-xshell/ash_test/ash-getopts/getopt_optarg.tests16
1 files changed, 16 insertions, 0 deletions
diff --git a/shell/ash_test/ash-getopts/getopt_optarg.tests b/shell/ash_test/ash-getopts/getopt_optarg.tests
new file mode 100755
index 000000000..b346284f0
--- /dev/null
+++ b/shell/ash_test/ash-getopts/getopt_optarg.tests
@@ -0,0 +1,16 @@
+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'"
+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'"
+done
+echo "exited: var:'$var' OPTIND:$OPTIND OPTARG:'$OPTARG'"