[git commit] hush: fix a backslash-removal bug in case

Denys Vlasenko vda.linux at googlemail.com
Mon Apr 2 15:25:18 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=abf755615e5f20c3bbe7534fa29c72fd684ea616
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
run_list                                            1270    1053    -217

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash_test/ash-quoting/bkslash_case2.right   |  3 +++
 shell/ash_test/ash-quoting/bkslash_case2.tests   | 13 +++++++++++++
 shell/hush.c                                     |  8 +++++---
 shell/hush_test/hush-quoting/bkslash_case2.right |  3 +++
 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 @@
+ok1
+ok2
+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 @@
+x='\abc'
+
+case "$x" in
+\\*) echo ok1;;
+*)   echo BUG1;;
+esac
+
+case $x in
+\\*) echo ok2;;
+*)   echo BUG2;;
+esac
+
+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)
 	return (char*)list;
 }
 
-#if ENABLE_HUSH_CASE
+#if 0
 static char* expand_strvec_to_string(char **argv)
 {
 	char **list;
@@ -8731,8 +8731,10 @@ static int run_list(struct pipe *pi)
 #if ENABLE_HUSH_CASE
 		if (rword == RES_CASE) {
 			debug_printf_exec("CASE cond_code:%d\n", cond_code);
-			case_word = expand_strvec_to_string(pi->cmds->argv);
-			unbackslash(case_word);
+			case_word = expand_string_to_string(pi->cmds->argv[0], 1);
+			debug_printf_exec("CASE word1:'%s'\n", case_word);
+			//unbackslash(case_word);
+			//debug_printf_exec("CASE word2:'%s'\n", case_word);
 			continue;
 		}
 		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 @@
+ok1
+ok2
+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 @@
+x='\abc'
+
+case "$x" in
+\\*) echo ok1;;
+*)   echo BUG1;;
+esac
+
+case $x in
+\\*) echo ok2;;
+*)   echo BUG2;;
+esac
+
+echo Ok:$?


More information about the busybox-cvs mailing list