diff options
Diffstat (limited to 'shell/ash_test')
| -rw-r--r-- | shell/ash_test/ash-getopts/getopt_nested.right | 14 | ||||
| -rwxr-xr-x | shell/ash_test/ash-getopts/getopt_nested.tests | 21 |
2 files changed, 35 insertions, 0 deletions
diff --git a/shell/ash_test/ash-getopts/getopt_nested.right b/shell/ash_test/ash-getopts/getopt_nested.right new file mode 100644 index 000000000..b0c339db1 --- /dev/null +++ b/shell/ash_test/ash-getopts/getopt_nested.right | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | var:a | ||
| 2 | var:b | ||
| 3 | var:c | ||
| 4 | var:a | ||
| 5 | var:b | ||
| 6 | var:c | ||
| 7 | Illegal option -d | ||
| 8 | var:? | ||
| 9 | Illegal option -e | ||
| 10 | var:? | ||
| 11 | Illegal option -f | ||
| 12 | var:? | ||
| 13 | var:a | ||
| 14 | End: var:? OPTIND:6 | ||
diff --git a/shell/ash_test/ash-getopts/getopt_nested.tests b/shell/ash_test/ash-getopts/getopt_nested.tests new file mode 100755 index 000000000..1b48b4075 --- /dev/null +++ b/shell/ash_test/ash-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 | |||
| 10 | loop=99 | ||
| 11 | while 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 | ||
| 16 | done | ||
| 17 | echo "End: var:$var OPTIND:$OPTIND" | ||
| 18 | |||
| 19 | ) 2>&1 \ | ||
| 20 | | sed -e 's/ unrecognized option: / invalid option -- /' \ | ||
| 21 | -e 's/ illegal option -- / invalid option -- /' \ | ||
