ash: parser: Save and restore heredoclist in expandstr
Upstream commit: Date: Sun, 17 May 2020 23:36:25 +1000 parser: Save and restore heredoclist in expandstr On Sun, May 17, 2020 at 01:19:28PM +0100, Harald van Dijk wrote: > This still does not restore the state completely. It does not clean up any > pending heredocs. I see: > > $ PS1='$(<<EOF "' > src/dash: 1: Syntax error: Unterminated quoted string > $(<<EOF ": > > > > That is, after entering the ':' command, the shell is still trying to read > the heredoc from the prompt. This patch saves and restores the heredoclist in expandstr. It also removes a bunch of unnecessary volatiles as those variables are only referenced in case of a longjmp other than one started by a signal like SIGINT. function old new delta expandstr 268 255 -13 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
30af5938af
commit
1c06ddd8bb
19
shell/ash.c
19
shell/ash.c
@ -13359,23 +13359,26 @@ parseheredoc(void)
|
|||||||
static const char *
|
static const char *
|
||||||
expandstr(const char *ps, int syntax_type)
|
expandstr(const char *ps, int syntax_type)
|
||||||
{
|
{
|
||||||
union node n;
|
struct parsefile *file_stop;
|
||||||
|
struct jmploc *volatile savehandler;
|
||||||
|
struct heredoc *saveheredoclist;
|
||||||
|
const char *result;
|
||||||
int saveprompt;
|
int saveprompt;
|
||||||
struct parsefile *file_stop = g_parsefile;
|
|
||||||
volatile int saveint;
|
|
||||||
struct jmploc *volatile savehandler = exception_handler;
|
|
||||||
struct jmploc jmploc;
|
struct jmploc jmploc;
|
||||||
const char *volatile result;
|
union node n;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
file_stop = g_parsefile;
|
||||||
|
|
||||||
/* XXX Fix (char *) cast. */
|
/* XXX Fix (char *) cast. */
|
||||||
setinputstring((char *)ps);
|
setinputstring((char *)ps);
|
||||||
|
|
||||||
|
saveheredoclist = heredoclist;
|
||||||
|
heredoclist = NULL;
|
||||||
saveprompt = doprompt;
|
saveprompt = doprompt;
|
||||||
doprompt = 0;
|
doprompt = 0;
|
||||||
result = ps;
|
result = ps;
|
||||||
|
savehandler = exception_handler;
|
||||||
SAVE_INT(saveint);
|
|
||||||
err = setjmp(jmploc.loc);
|
err = setjmp(jmploc.loc);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
@ -13402,11 +13405,11 @@ out:
|
|||||||
exception_handler = savehandler;
|
exception_handler = savehandler;
|
||||||
if (err && exception_type != EXERROR)
|
if (err && exception_type != EXERROR)
|
||||||
longjmp(exception_handler->loc, 1);
|
longjmp(exception_handler->loc, 1);
|
||||||
RESTORE_INT(saveint);
|
|
||||||
|
|
||||||
doprompt = saveprompt;
|
doprompt = saveprompt;
|
||||||
/* Try: PS1='`xxx(`' */
|
/* Try: PS1='`xxx(`' */
|
||||||
unwindfiles(file_stop);
|
unwindfiles(file_stop);
|
||||||
|
heredoclist = saveheredoclist;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user