diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/shell/ash.c b/shell/ash.c index ad7b8f4dd..b82c51029 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -13747,6 +13747,10 @@ expandstr(const char *ps, int syntax_type) | |||
13747 | { | 13747 | { |
13748 | union node n; | 13748 | union node n; |
13749 | int saveprompt; | 13749 | int saveprompt; |
13750 | struct parsefile *file_stop = g_parsefile; | ||
13751 | volatile int saveint; | ||
13752 | struct jmploc *volatile savehandler = exception_handler; | ||
13753 | struct jmploc jmploc; | ||
13750 | 13754 | ||
13751 | /* XXX Fix (char *) cast. */ | 13755 | /* XXX Fix (char *) cast. */ |
13752 | setinputstring((char *)ps); | 13756 | setinputstring((char *)ps); |
@@ -13758,29 +13762,35 @@ expandstr(const char *ps, int syntax_type) | |||
13758 | * Try a prompt with syntactically wrong command: | 13762 | * Try a prompt with syntactically wrong command: |
13759 | * PS1='$(date "+%H:%M:%S) > ' | 13763 | * PS1='$(date "+%H:%M:%S) > ' |
13760 | */ | 13764 | */ |
13761 | { | 13765 | SAVE_INT(saveint); |
13762 | volatile int saveint; | 13766 | if (setjmp(jmploc.loc) == 0) { |
13763 | struct jmploc *volatile savehandler = exception_handler; | 13767 | exception_handler = &jmploc; |
13764 | struct jmploc jmploc; | 13768 | readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0); |
13765 | SAVE_INT(saveint); | ||
13766 | if (setjmp(jmploc.loc) == 0) { | ||
13767 | exception_handler = &jmploc; | ||
13768 | readtoken1(pgetc(), syntax_type, FAKEEOFMARK, 0); | ||
13769 | } | ||
13770 | exception_handler = savehandler; | ||
13771 | RESTORE_INT(saveint); | ||
13772 | } | 13769 | } |
13770 | exception_handler = savehandler; | ||
13771 | RESTORE_INT(saveint); | ||
13773 | 13772 | ||
13774 | doprompt = saveprompt; | 13773 | doprompt = saveprompt; |
13775 | 13774 | ||
13776 | popfile(); | 13775 | /* Try: PS1='`xxx(`' */ |
13776 | unwindfiles(file_stop); | ||
13777 | 13777 | ||
13778 | n.narg.type = NARG; | 13778 | n.narg.type = NARG; |
13779 | n.narg.next = NULL; | 13779 | n.narg.next = NULL; |
13780 | n.narg.text = wordtext; | 13780 | n.narg.text = wordtext; |
13781 | n.narg.backquote = backquotelist; | 13781 | n.narg.backquote = backquotelist; |
13782 | 13782 | ||
13783 | expandarg(&n, NULL, EXP_QUOTED); | 13783 | /* expandarg() might fail too: |
13784 | * PS1='$((123+))' | ||
13785 | */ | ||
13786 | SAVE_INT(saveint); | ||
13787 | if (setjmp(jmploc.loc) == 0) { | ||
13788 | exception_handler = &jmploc; | ||
13789 | expandarg(&n, NULL, EXP_QUOTED); | ||
13790 | } | ||
13791 | exception_handler = savehandler; | ||
13792 | RESTORE_INT(saveint); | ||
13793 | |||
13784 | return stackblock(); | 13794 | return stackblock(); |
13785 | } | 13795 | } |
13786 | 13796 | ||