aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-getopts/getopt_nested.right14
-rwxr-xr-xshell/hush_test/hush-getopts/getopt_nested.tests21
2 files changed, 35 insertions, 0 deletions
diff --git a/shell/hush_test/hush-getopts/getopt_nested.right b/shell/hush_test/hush-getopts/getopt_nested.right
new file mode 100644
index 000000000..0218dba56
--- /dev/null
+++ b/shell/hush_test/hush-getopts/getopt_nested.right
@@ -0,0 +1,14 @@
1var:a
2var:b
3var:c
4var:a
5var:b
6var:c
7./getopt_nested.tests: invalid option -- d
8var:?
9./getopt_nested.tests: invalid option -- e
10var:?
11./getopt_nested.tests: invalid option -- f
12var:?
13var:a
14End: var:? OPTIND:6
diff --git a/shell/hush_test/hush-getopts/getopt_nested.tests b/shell/hush_test/hush-getopts/getopt_nested.tests
new file mode 100755
index 000000000..1b48b4075
--- /dev/null
+++ b/shell/hush_test/hush-getopts/getopt_nested.tests
@@ -0,0 +1,21 @@
1# Test that there is no interference of getopt()
2# in getopts and unset.
3# It's unclear what "correct" OPTIND values should be
4# for "b" and "c" results from "-bc": 2? 3?
5# What we focus on here is that all options are reported
6# correct number of times and in correct sequence.
7
8(
9
10loop=99
11while getopts "abc" var -a -bc -abc -def -a; do
12 echo "var:$var" #OPTIND:$OPTIND
13 # this may use getopt():
14 unset -ff func
15 test $((--loop)) = 0 && break # BUG if this triggers
16done
17echo "End: var:$var OPTIND:$OPTIND"
18
19) 2>&1 \
20| sed -e 's/ unrecognized option: / invalid option -- /' \
21 -e 's/ illegal option -- / invalid option -- /' \