hush: fix quoted "${notexist-}" expansion to not disappear
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 15 May 2019 11:39:19 +0000 (13:39 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 15 May 2019 11:39:19 +0000 (13:39 +0200)
function                                             old     new   delta
expand_one_var                                      2296    2311     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash_test/ash-vars/param_expand_default.right
shell/ash_test/ash-vars/param_expand_default.tests
shell/hush.c
shell/hush_test/hush-vars/param_expand_default.right
shell/hush_test/hush-vars/param_expand_default.tests

index 3eecd1375161942aa4bdbc4d0787f996236bbf5d..7a42f67e8ba79b3aac3afba399454ca135ab97a5 100644 (file)
@@ -5,3 +5,5 @@ _aaaa _aaaa _aaaa _aaaa _aaaa
 _ _ _ _word _word
 _ _ _ _ _word
 _fff _fff _fff _fff _fff
+1:1
+0:0
index 5e42d30e3854183e093f15317f56945e0b81f5ff..b5edfe1c5d19533c3177270f47820e0af2eb7b5c 100755 (executable)
@@ -21,3 +21,8 @@ echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
 
 f=fff
 echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
+
+set --
+set -- "${1-}"; echo 1:$#
+set --
+set -- ${1-}; echo 0:$#
index b612c80dad0b2b51e299a71676ddcb8e01b1c604..a103e81690789f496d9f63098427e37d55916cdc 100644 (file)
@@ -6132,6 +6132,12 @@ static int encode_then_append_var_plusminus(o_string *output, int n,
                /* string has no special chars
                 * && string has no $IFS chars
                 */
+               if (dquoted) {
+                       /* Prints 1 (quoted expansion is a "" word, not nothing):
+                        * set -- "${notexist-}"; echo $#
+                        */
+                       output->has_quoted_part = 1;
+               }
                return expand_vars_to_list(output, n, str);
        }
 
index acc71720533e07ff7187e34e56f912edb6b34bd6..dbade30038062d4a215eb9e8c325e629519f7e06 100644 (file)
@@ -6,3 +6,5 @@ _aaaa _aaaa _aaaa _aaaa _aaaa
 _ _ _ _word _word
 _ _ _ _ _word
 _fff _fff _fff _fff _fff
+1:1
+0:0
index 16e5f8efef177fb1584a6b333aa00cd56184afb5..754827ab3b62bad6f47cba349ed756edb2cf2173 100755 (executable)
@@ -22,3 +22,8 @@ echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
 
 f=fff
 echo _$f _${f-} _${f:-} _${f-word} _${f:-word}
+
+set --
+set -- "${1-}"; echo 1:$#
+set --
+set -- ${1-}; echo 0:$#