[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] ash: bash-compatible $'...' shouldn't expand in double quotes
From:       Denys Vlasenko <vda.linux () googlemail ! com>
Date:       2016-04-15 20:20:01
Message-ID: CAK1hOcPBPeHkRB3kPYHXYSryHHMOWAU-rErsT2edMMTtJPxKpw () mail ! gmail ! com
[Download RAW message or body]

Applied, thanks!

On Sun, Apr 3, 2016 at 11:43 PM, Ron Yorston <rmy@pobox.com> wrote:
> 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>
> ---
> shell/ash.c                                          | 2 +-
> shell/ash_test/ash-heredoc/heredoc4.right            | 1 +
> shell/ash_test/ash-heredoc/heredoc4.tests            | 3 +++
> shell/ash_test/ash-quoting/dollar_squote_bash1.right | 1 +
> shell/ash_test/ash-quoting/dollar_squote_bash1.tests | 1 +
> 5 files changed, 7 insertions(+), 1 deletion(-)
> create mode 100644 shell/ash_test/ash-heredoc/heredoc4.right
> create mode 100755 shell/ash_test/ash-heredoc/heredoc4.tests
> 
> diff --git a/shell/ash.c b/shell/ash.c
> index 5613e1f..6ac0f15 100644
> --- a/shell/ash.c
> +++ b/shell/ash.c
> @@ -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
> index 0000000..371b092
> --- /dev/null
> +++ b/shell/ash_test/ash-heredoc/heredoc4.right
> @@ -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
> index 0000000..642ddb3
> --- /dev/null
> +++ b/shell/ash_test/ash-heredoc/heredoc4.tests
> @@ -0,0 +1,3 @@
> +cat <<EOF
> +'$'
> +EOF
> diff --git a/shell/ash_test/ash-quoting/dollar_squote_bash1.right \
> b/shell/ash_test/ash-quoting/dollar_squote_bash1.right index 57536b1..9f4e25e \
>                 100644
> --- a/shell/ash_test/ash-quoting/dollar_squote_bash1.right
> +++ b/shell/ash_test/ash-quoting/dollar_squote_bash1.right
> @@ -1,4 +1,5 @@
> a      b
> +$'a\tb'
> a
> b c
> def
> diff --git a/shell/ash_test/ash-quoting/dollar_squote_bash1.tests \
> b/shell/ash_test/ash-quoting/dollar_squote_bash1.tests index 93a56ca..6fc411b \
>                 100755
> --- a/shell/ash_test/ash-quoting/dollar_squote_bash1.tests
> +++ b/shell/ash_test/ash-quoting/dollar_squote_bash1.tests
> @@ -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'
> --
> 2.5.5
> 
> _______________________________________________
> busybox mailing list
> busybox@busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic