ash: survive failures in $PS1 expansion. Closes 10371
function old new delta expandstr 120 209 +89 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
0fd5dbba8f
commit
a2e32b324e
1 changed files with 18 additions and 1 deletions
19
shell/ash.c
19
shell/ash.c
|
@ -12656,7 +12656,24 @@ expandstr(const char *ps, int syntax_type)
|
||||||
|
|
||||||
saveprompt = doprompt;
|
saveprompt = doprompt;
|
||||||
doprompt = 0;
|
doprompt = 0;
|
||||||
readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
|
|
||||||
|
/* readtoken1() might die horribly.
|
||||||
|
* Try a prompt with syntacticallyt wrong command:
|
||||||
|
* PS1='$(date "+%H:%M:%S) > '
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
volatile int saveint;
|
||||||
|
struct jmploc *volatile savehandler = exception_handler;
|
||||||
|
struct jmploc jmploc;
|
||||||
|
SAVE_INT(saveint);
|
||||||
|
if (setjmp(jmploc.loc) == 0) {
|
||||||
|
exception_handler = &jmploc;
|
||||||
|
readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0);
|
||||||
|
}
|
||||||
|
exception_handler = savehandler;
|
||||||
|
RESTORE_INT(saveint);
|
||||||
|
}
|
||||||
|
|
||||||
doprompt = saveprompt;
|
doprompt = saveprompt;
|
||||||
|
|
||||||
popfile();
|
popfile();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue