diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-02 17:25:18 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-02 17:25:18 +0200 |
| commit | abf755615e5f20c3bbe7534fa29c72fd684ea616 (patch) | |
| tree | 281642aba72686a4179456235c73c3392d5a5bf5 /shell | |
| parent | 9a95df90463ee0eddc0585f0e5affa827701fdfb (diff) | |
| download | busybox-w32-abf755615e5f20c3bbe7534fa29c72fd684ea616.tar.gz busybox-w32-abf755615e5f20c3bbe7534fa29c72fd684ea616.tar.bz2 busybox-w32-abf755615e5f20c3bbe7534fa29c72fd684ea616.zip | |
hush: fix a backslash-removal bug in case
function old new delta
run_list 1270 1053 -217
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash_test/ash-quoting/bkslash_case2.right | 3 | ||||
| -rwxr-xr-x | shell/ash_test/ash-quoting/bkslash_case2.tests | 13 | ||||
| -rw-r--r-- | shell/hush.c | 8 | ||||
| -rw-r--r-- | shell/hush_test/hush-quoting/bkslash_case2.right | 3 | ||||
| -rwxr-xr-x | shell/hush_test/hush-quoting/bkslash_case2.tests | 13 |
5 files changed, 37 insertions, 3 deletions
diff --git a/shell/ash_test/ash-quoting/bkslash_case2.right b/shell/ash_test/ash-quoting/bkslash_case2.right new file mode 100644 index 000000000..8d2038bff --- /dev/null +++ b/shell/ash_test/ash-quoting/bkslash_case2.right | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | ok1 | ||
| 2 | ok2 | ||
| 3 | Ok:0 | ||
diff --git a/shell/ash_test/ash-quoting/bkslash_case2.tests b/shell/ash_test/ash-quoting/bkslash_case2.tests new file mode 100755 index 000000000..348ddc236 --- /dev/null +++ b/shell/ash_test/ash-quoting/bkslash_case2.tests | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | x='\abc' | ||
| 2 | |||
| 3 | case "$x" in | ||
| 4 | \\*) echo ok1;; | ||
| 5 | *) echo BUG1;; | ||
| 6 | esac | ||
| 7 | |||
| 8 | case $x in | ||
| 9 | \\*) echo ok2;; | ||
| 10 | *) echo BUG2;; | ||
| 11 | esac | ||
| 12 | |||
| 13 | echo Ok:$? | ||
diff --git a/shell/hush.c b/shell/hush.c index 1779009e0..867a921ec 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
| @@ -6347,7 +6347,7 @@ static char *expand_string_to_string(const char *str, int do_unbackslash) | |||
| 6347 | return (char*)list; | 6347 | return (char*)list; |
| 6348 | } | 6348 | } |
| 6349 | 6349 | ||
| 6350 | #if ENABLE_HUSH_CASE | 6350 | #if 0 |
| 6351 | static char* expand_strvec_to_string(char **argv) | 6351 | static char* expand_strvec_to_string(char **argv) |
| 6352 | { | 6352 | { |
| 6353 | char **list; | 6353 | char **list; |
| @@ -8731,8 +8731,10 @@ static int run_list(struct pipe *pi) | |||
| 8731 | #if ENABLE_HUSH_CASE | 8731 | #if ENABLE_HUSH_CASE |
| 8732 | if (rword == RES_CASE) { | 8732 | if (rword == RES_CASE) { |
| 8733 | debug_printf_exec("CASE cond_code:%d\n", cond_code); | 8733 | debug_printf_exec("CASE cond_code:%d\n", cond_code); |
| 8734 | case_word = expand_strvec_to_string(pi->cmds->argv); | 8734 | case_word = expand_string_to_string(pi->cmds->argv[0], 1); |
| 8735 | unbackslash(case_word); | 8735 | debug_printf_exec("CASE word1:'%s'\n", case_word); |
| 8736 | //unbackslash(case_word); | ||
| 8737 | //debug_printf_exec("CASE word2:'%s'\n", case_word); | ||
| 8736 | continue; | 8738 | continue; |
| 8737 | } | 8739 | } |
| 8738 | if (rword == RES_MATCH) { | 8740 | if (rword == RES_MATCH) { |
diff --git a/shell/hush_test/hush-quoting/bkslash_case2.right b/shell/hush_test/hush-quoting/bkslash_case2.right new file mode 100644 index 000000000..8d2038bff --- /dev/null +++ b/shell/hush_test/hush-quoting/bkslash_case2.right | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | ok1 | ||
| 2 | ok2 | ||
| 3 | Ok:0 | ||
diff --git a/shell/hush_test/hush-quoting/bkslash_case2.tests b/shell/hush_test/hush-quoting/bkslash_case2.tests new file mode 100755 index 000000000..348ddc236 --- /dev/null +++ b/shell/hush_test/hush-quoting/bkslash_case2.tests | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | x='\abc' | ||
| 2 | |||
| 3 | case "$x" in | ||
| 4 | \\*) echo ok1;; | ||
| 5 | *) echo BUG1;; | ||
| 6 | esac | ||
| 7 | |||
| 8 | case $x in | ||
| 9 | \\*) echo ok2;; | ||
| 10 | *) echo BUG2;; | ||
| 11 | esac | ||
| 12 | |||
| 13 | echo Ok:$? | ||
