diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-29 13:38:30 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-08-29 13:38:30 +0200 |
commit | 238ff98bb85adfb5563d10b37ea4c33fef3af2f2 (patch) | |
tree | a556435d7011ee928419d26a9d7d796745f97f62 /shell/ash_test | |
parent | 0d1eaf407c3d077f1d6ec97ceffbafbe7591ecbf (diff) | |
download | busybox-w32-238ff98bb85adfb5563d10b37ea4c33fef3af2f2.tar.gz busybox-w32-238ff98bb85adfb5563d10b37ea4c33fef3af2f2.tar.bz2 busybox-w32-238ff98bb85adfb5563d10b37ea4c33fef3af2f2.zip |
hush: fix "getopts" builtin to not be upset by other builtins calling getopt()
function old new delta
builtin_getopts 363 403 +40
unset_local_var_len 185 215 +30
set_local_var 440 466 +26
reset_traps_to_defaults 151 157 +6
pseudo_exec_argv 320 326 +6
install_special_sighandlers 52 58 +6
pick_sighandler 62 65 +3
execvp_or_die 85 88 +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 8/0 up/down: 120/0) Total: 120 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
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 -- /' \ | ||