ash: parser: Save/restore here-documents in command substitution
Upstream comment: Date: Sat, 19 May 2018 02:39:42 +0800 parser: Save/restore here-documents in command substitution This patch changes the parsing of here-documents within command substitution, both old style and new style. In particular, the original here-document list is saved upon the beginning of parsing command substitution and restored when exiting. This means that here-documents outside of command substitution can no longer be filled by text within it and vice-versa. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
afc91faedd
commit
74aaf05170
25
shell/ash.c
25
shell/ash.c
@ -12733,6 +12733,7 @@ parsebackq: {
|
|||||||
union node *n;
|
union node *n;
|
||||||
char *str;
|
char *str;
|
||||||
size_t savelen;
|
size_t savelen;
|
||||||
|
struct heredoc *saveheredoclist;
|
||||||
smallint saveprompt = 0;
|
smallint saveprompt = 0;
|
||||||
|
|
||||||
str = NULL;
|
str = NULL;
|
||||||
@ -12808,6 +12809,9 @@ parsebackq: {
|
|||||||
*nlpp = stzalloc(sizeof(**nlpp));
|
*nlpp = stzalloc(sizeof(**nlpp));
|
||||||
/* (*nlpp)->next = NULL; - stzalloc did it */
|
/* (*nlpp)->next = NULL; - stzalloc did it */
|
||||||
|
|
||||||
|
saveheredoclist = heredoclist;
|
||||||
|
heredoclist = NULL;
|
||||||
|
|
||||||
if (oldstyle) {
|
if (oldstyle) {
|
||||||
saveprompt = doprompt;
|
saveprompt = doprompt;
|
||||||
doprompt = 0;
|
doprompt = 0;
|
||||||
@ -12817,18 +12821,21 @@ parsebackq: {
|
|||||||
|
|
||||||
if (oldstyle)
|
if (oldstyle)
|
||||||
doprompt = saveprompt;
|
doprompt = saveprompt;
|
||||||
else if (readtoken() != TRP)
|
else {
|
||||||
raise_error_unexpected_syntax(TRP);
|
if (readtoken() != TRP)
|
||||||
|
raise_error_unexpected_syntax(TRP);
|
||||||
|
setinputstring(nullstr);
|
||||||
|
parseheredoc();
|
||||||
|
}
|
||||||
|
|
||||||
|
heredoclist = saveheredoclist;
|
||||||
|
|
||||||
(*nlpp)->n = n;
|
(*nlpp)->n = n;
|
||||||
if (oldstyle) {
|
/* Start reading from old file again. */
|
||||||
/*
|
popfile();
|
||||||
* Start reading from old file again, ignoring any pushed back
|
/* Ignore any pushed back tokens left from the backquote parsing. */
|
||||||
* tokens left from the backquote parsing
|
if (oldstyle)
|
||||||
*/
|
|
||||||
popfile();
|
|
||||||
tokpushback = 0;
|
tokpushback = 0;
|
||||||
}
|
|
||||||
while (stackblocksize() <= savelen)
|
while (stackblocksize() <= savelen)
|
||||||
growstackblock();
|
growstackblock();
|
||||||
STARTSTACKSTR(out);
|
STARTSTACKSTR(out);
|
||||||
|
Loading…
Reference in New Issue
Block a user