diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-01 16:38:32 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-04-01 16:38:32 +0200 |
commit | 41fddb43729373740bfba82da83373ec5ba49fc8 (patch) | |
tree | 94c8010ca829d3bfe5ee02d654c65d37240c98c5 | |
parent | 1e5111b0f80b1f3d7f2fc8254cb70de067317403 (diff) | |
download | busybox-w32-41fddb43729373740bfba82da83373ec5ba49fc8.tar.gz busybox-w32-41fddb43729373740bfba82da83373ec5ba49fc8.tar.bz2 busybox-w32-41fddb43729373740bfba82da83373ec5ba49fc8.zip |
parser: Fix backquote support in here-document EOF mark
Upstream commit:
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date: Thu Mar 15 18:27:30 2018 +0800
parser: Fix backquote support in here-document EOF mark
Currently using backquotes in a here-document EOF mark is broken
because dash tries to do command substitution on it. This patch
fixes it by checking whether we're looking for an EOF mark during
tokenisation.
Reported-by: Harald van Dijk <harald@gigawatt.nl>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
With added fix for quoted-ness of the EOF mark.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 6 | ||||
-rw-r--r-- | shell/ash_test/ash-heredoc/heredoc_backquote1.right | 5 | ||||
-rwxr-xr-x | shell/ash_test/ash-heredoc/heredoc_backquote1.tests | 10 | ||||
-rw-r--r-- | shell/hush_test/hush-heredoc/heredoc_backquote1.right | 5 | ||||
-rwxr-xr-x | shell/hush_test/hush-heredoc/heredoc_backquote1.tests | 10 |
5 files changed, 36 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c index 454bc3317..cf1d062fb 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -12093,6 +12093,12 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) | |||
12093 | break; | 12093 | break; |
12094 | #endif | 12094 | #endif |
12095 | case CBQUOTE: /* '`' */ | 12095 | case CBQUOTE: /* '`' */ |
12096 | if (checkkwd & CHKEOFMARK) { | ||
12097 | quotef = 1; | ||
12098 | USTPUTC('`', out); | ||
12099 | break; | ||
12100 | } | ||
12101 | |||
12096 | PARSEBACKQOLD(); | 12102 | PARSEBACKQOLD(); |
12097 | break; | 12103 | break; |
12098 | case CENDFILE: | 12104 | case CENDFILE: |
diff --git a/shell/ash_test/ash-heredoc/heredoc_backquote1.right b/shell/ash_test/ash-heredoc/heredoc_backquote1.right new file mode 100644 index 000000000..0be2a3296 --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc_backquote1.right | |||
@@ -0,0 +1,5 @@ | |||
1 | heredoc1 | ||
2 | Ok1:0 | ||
3 | heredoc2 | ||
4 | EO`false`F | ||
5 | Ok2:0 | ||
diff --git a/shell/ash_test/ash-heredoc/heredoc_backquote1.tests b/shell/ash_test/ash-heredoc/heredoc_backquote1.tests new file mode 100755 index 000000000..ec3d8fe1d --- /dev/null +++ b/shell/ash_test/ash-heredoc/heredoc_backquote1.tests | |||
@@ -0,0 +1,10 @@ | |||
1 | cat <<EO`true`F | ||
2 | heredoc1 | ||
3 | EO`true`F | ||
4 | echo Ok1:$? | ||
5 | |||
6 | cat <<EO`true`F | ||
7 | heredoc2 | ||
8 | EO`false`F | ||
9 | EO`true`F | ||
10 | echo Ok2:$? | ||
diff --git a/shell/hush_test/hush-heredoc/heredoc_backquote1.right b/shell/hush_test/hush-heredoc/heredoc_backquote1.right new file mode 100644 index 000000000..0be2a3296 --- /dev/null +++ b/shell/hush_test/hush-heredoc/heredoc_backquote1.right | |||
@@ -0,0 +1,5 @@ | |||
1 | heredoc1 | ||
2 | Ok1:0 | ||
3 | heredoc2 | ||
4 | EO`false`F | ||
5 | Ok2:0 | ||
diff --git a/shell/hush_test/hush-heredoc/heredoc_backquote1.tests b/shell/hush_test/hush-heredoc/heredoc_backquote1.tests new file mode 100755 index 000000000..ec3d8fe1d --- /dev/null +++ b/shell/hush_test/hush-heredoc/heredoc_backquote1.tests | |||
@@ -0,0 +1,10 @@ | |||
1 | cat <<EO`true`F | ||
2 | heredoc1 | ||
3 | EO`true`F | ||
4 | echo Ok1:$? | ||
5 | |||
6 | cat <<EO`true`F | ||
7 | heredoc2 | ||
8 | EO`false`F | ||
9 | EO`true`F | ||
10 | echo Ok2:$? | ||