aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-05-15 13:39:19 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2019-05-15 13:39:19 +0200
commit9e0adb9b09ec14afe2e5a222dda1c447f336ea06 (patch)
tree49ba7977aab90ee21b90f30cd49d68a1bb715585 /shell
parent8402969d4892891ddfde524fbb9ee73e076f3771 (diff)
downloadbusybox-w32-9e0adb9b09ec14afe2e5a222dda1c447f336ea06.tar.gz
busybox-w32-9e0adb9b09ec14afe2e5a222dda1c447f336ea06.tar.bz2
busybox-w32-9e0adb9b09ec14afe2e5a222dda1c447f336ea06.zip
hush: fix quoted "${notexist-}" expansion to not disappear
function old new delta expand_one_var 2296 2311 +15 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash_test/ash-vars/param_expand_default.right2
-rwxr-xr-xshell/ash_test/ash-vars/param_expand_default.tests5
-rw-r--r--shell/hush.c6
-rw-r--r--shell/hush_test/hush-vars/param_expand_default.right2
-rwxr-xr-xshell/hush_test/hush-vars/param_expand_default.tests5
5 files changed, 20 insertions, 0 deletions
diff --git a/shell/ash_test/ash-vars/param_expand_default.right b/shell/ash_test/ash-vars/param_expand_default.right
index 3eecd1375..7a42f67e8 100644
--- a/shell/ash_test/ash-vars/param_expand_default.right
+++ b/shell/ash_test/ash-vars/param_expand_default.right
@@ -5,3 +5,5 @@ _aaaa _aaaa _aaaa _aaaa _aaaa
5_ _ _ _word _word 5_ _ _ _word _word
6_ _ _ _ _word 6_ _ _ _ _word
7_fff _fff _fff _fff _fff 7_fff _fff _fff _fff _fff
81:1
90:0
diff --git a/shell/ash_test/ash-vars/param_expand_default.tests b/shell/ash_test/ash-vars/param_expand_default.tests
index 5e42d30e3..b5edfe1c5 100755
--- a/shell/ash_test/ash-vars/param_expand_default.tests
+++ b/shell/ash_test/ash-vars/param_expand_default.tests
@@ -21,3 +21,8 @@ echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
21 21
22f=fff 22f=fff
23echo _$f _${f-} _${f:-} _${f-word} _${f:-word} 23echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
24
25set --
26set -- "${1-}"; echo 1:$#
27set --
28set -- ${1-}; echo 0:$#
diff --git a/shell/hush.c b/shell/hush.c
index b612c80da..a103e8169 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6132,6 +6132,12 @@ static int encode_then_append_var_plusminus(o_string *output, int n,
6132 /* string has no special chars 6132 /* string has no special chars
6133 * && string has no $IFS chars 6133 * && string has no $IFS chars
6134 */ 6134 */
6135 if (dquoted) {
6136 /* Prints 1 (quoted expansion is a "" word, not nothing):
6137 * set -- "${notexist-}"; echo $#
6138 */
6139 output->has_quoted_part = 1;
6140 }
6135 return expand_vars_to_list(output, n, str); 6141 return expand_vars_to_list(output, n, str);
6136 } 6142 }
6137 6143
diff --git a/shell/hush_test/hush-vars/param_expand_default.right b/shell/hush_test/hush-vars/param_expand_default.right
index acc717205..dbade3003 100644
--- a/shell/hush_test/hush-vars/param_expand_default.right
+++ b/shell/hush_test/hush-vars/param_expand_default.right
@@ -6,3 +6,5 @@ _aaaa _aaaa _aaaa _aaaa _aaaa
6_ _ _ _word _word 6_ _ _ _word _word
7_ _ _ _ _word 7_ _ _ _ _word
8_fff _fff _fff _fff _fff 8_fff _fff _fff _fff _fff
91:1
100:0
diff --git a/shell/hush_test/hush-vars/param_expand_default.tests b/shell/hush_test/hush-vars/param_expand_default.tests
index 16e5f8efe..754827ab3 100755
--- a/shell/hush_test/hush-vars/param_expand_default.tests
+++ b/shell/hush_test/hush-vars/param_expand_default.tests
@@ -22,3 +22,8 @@ echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
22 22
23f=fff 23f=fff
24echo _$f _${f-} _${f:-} _${f-word} _${f:-word} 24echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
25
26set --
27set -- "${1-}"; echo 1:$#
28set --
29set -- ${1-}; echo 0:$#