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>
This commit is contained in:
parent
1e5111b0f8
commit
41fddb4372
@ -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:
|
||||
|
5
shell/ash_test/ash-heredoc/heredoc_backquote1.right
Normal file
5
shell/ash_test/ash-heredoc/heredoc_backquote1.right
Normal file
@ -0,0 +1,5 @@
|
||||
heredoc1
|
||||
Ok1:0
|
||||
heredoc2
|
||||
EO`false`F
|
||||
Ok2:0
|
10
shell/ash_test/ash-heredoc/heredoc_backquote1.tests
Executable file
10
shell/ash_test/ash-heredoc/heredoc_backquote1.tests
Executable file
@ -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:$?
|
5
shell/hush_test/hush-heredoc/heredoc_backquote1.right
Normal file
5
shell/hush_test/hush-heredoc/heredoc_backquote1.right
Normal file
@ -0,0 +1,5 @@
|
||||
heredoc1
|
||||
Ok1:0
|
||||
heredoc2
|
||||
EO`false`F
|
||||
Ok2:0
|
10
shell/hush_test/hush-heredoc/heredoc_backquote1.tests
Executable file
10
shell/hush_test/hush-heredoc/heredoc_backquote1.tests
Executable file
@ -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:$?
|
Loading…
Reference in New Issue
Block a user