ash: bash-compatible $'...' shouldn't expand in double quotes
authorRon Yorston <rmy@pobox.com>
Sun, 3 Apr 2016 21:43:14 +0000 (22:43 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 15 Apr 2016 20:16:46 +0000 (22:16 +0200)
Bash doesn't expand its $'...' construct in double quotes:

   $ echo "$'a\tb'"
   $'a\tb'

Change BusyBox ash to do the same.  This also fixes a problem with
here documents where BusyBox ash gave an incorrect result for:

   $ cat <<EOF
   > '$'
   > EOF
   '$'

Reported-by: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c
shell/ash_test/ash-heredoc/heredoc4.right [new file with mode: 0644]
shell/ash_test/ash-heredoc/heredoc4.tests [new file with mode: 0755]
shell/ash_test/ash-quoting/dollar_squote_bash1.right
shell/ash_test/ash-quoting/dollar_squote_bash1.tests

index 13eeab34b2e2ef15aeab9cf548d5f58c292016d9..da9c95045714f04263b844bb9a5b2fb45090c112 100644 (file)
@@ -11500,7 +11500,7 @@ parsesub: {
         || (c != '(' && c != '{' && !is_name(c) && !is_special(c))
        ) {
 #if ENABLE_ASH_BASH_COMPAT
-               if (c == '\'')
+               if (syntax != DQSYNTAX && c == '\'')
                        bash_dollar_squote = 1;
                else
 #endif
diff --git a/shell/ash_test/ash-heredoc/heredoc4.right b/shell/ash_test/ash-heredoc/heredoc4.right
new file mode 100644 (file)
index 0000000..371b092
--- /dev/null
@@ -0,0 +1 @@
+'$'
diff --git a/shell/ash_test/ash-heredoc/heredoc4.tests b/shell/ash_test/ash-heredoc/heredoc4.tests
new file mode 100755 (executable)
index 0000000..642ddb3
--- /dev/null
@@ -0,0 +1,3 @@
+cat <<EOF
+'$'
+EOF
index 57536b1d942c43c7ebad361455b2efa23b6e1fb7..9f4e25efa6316aa41b78488c64d68f8c5c85e5f6 100644 (file)
@@ -1,4 +1,5 @@
 a      b
+$'a\tb'
 a
 b c
 def
index 93a56cac3ab9a088a0a510aa190a98b74aa80045..6fc411b938823e471c04ce6664d6bb461c197a60 100755 (executable)
@@ -1,4 +1,5 @@
 echo $'a\tb'
+echo "$'a\tb'"
 echo $'a\nb' $'c\nd''ef'
 echo $'a\'b' $'c\"d' $'e\\f'
 echo $'a\63b' $'c\063b' $'e\0633f'