[git commit] parser: Fix backquote support in here-document EOF mark

Denys Vlasenko vda.linux at googlemail.com
Sun Apr 1 14:38:32 UTC 2018


commit: https://git.busybox.net/busybox/commit/?id=41fddb43729373740bfba82da83373ec5ba49fc8
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

Upstream commit:

    Author: Herbert Xu <herbert at 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 at gigawatt.nl>
    Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>

With added fix for quoted-ness of the EOF mark.

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 shell/ash.c                                           |  6 ++++++
 shell/ash_test/ash-heredoc/heredoc_backquote1.right   |  5 +++++
 shell/ash_test/ash-heredoc/heredoc_backquote1.tests   | 10 ++++++++++
 shell/hush_test/hush-heredoc/heredoc_backquote1.right |  5 +++++
 shell/hush_test/hush-heredoc/heredoc_backquote1.tests | 10 ++++++++++
 5 files changed, 36 insertions(+)

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)
 			break;
 #endif
 		case CBQUOTE:   /* '`' */
+			if (checkkwd & CHKEOFMARK) {
+				quotef = 1;
+				USTPUTC('`', out);
+				break;
+			}
+
 			PARSEBACKQOLD();
 			break;
 		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 @@
+heredoc1
+Ok1:0
+heredoc2
+EO`false`F
+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 @@
+cat <<EO`true`F
+heredoc1
+EO`true`F
+echo Ok1:$?
+
+cat <<EO`true`F
+heredoc2
+EO`false`F
+EO`true`F
+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 @@
+heredoc1
+Ok1:0
+heredoc2
+EO`false`F
+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 @@
+cat <<EO`true`F
+heredoc1
+EO`true`F
+echo Ok1:$?
+
+cat <<EO`true`F
+heredoc2
+EO`false`F
+EO`true`F
+echo Ok2:$?


More information about the busybox-cvs mailing list