summaryrefslogtreecommitdiff
path: root/shell/hush_test/hush-getopts/getopt_optarg.tests
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush_test/hush-getopts/getopt_optarg.tests')
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_optarg.tests16
1 files changed, 16 insertions, 0 deletions
diff --git a/shell/hush_test/hush-getopts/getopt_optarg.tests b/shell/hush_test/hush-getopts/getopt_optarg.tests
new file mode 100755
index 0000000..b346284
--- /dev/null
+++ b/shell/hush_test/hush-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'"