ash: only catch unexpected exceptions in PS1 expansion
authorRon Yorston <rmy@pobox.com>
Mon, 29 Jul 2019 08:51:14 +0000 (09:51 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 31 Jul 2019 11:44:32 +0000 (13:44 +0200)
Commit d1a2fa2a4 (ash: catch error in arithmetic expansion in PS1)
catches all exceptions raised by expandarg().  Some exceptions, such as
the EXEXIT raised when command expansion is used, are expected:

   export PS1='$(echo "$ ")'

These should be processed normally or the shell hangs at the prompt.

function                                             old     new   delta
expandstr                                            344     353      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 9/0)                 Total: 9 bytes

Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c

index e3bbac9a0c0f7d053229f42b3960ca7a55d74b17..c0352602b9beb82959bf5bdbd14850e8a23931d7 100644 (file)
@@ -13126,6 +13126,8 @@ expandstr(const char *ps, int syntax_type)
        if (setjmp(jmploc.loc) == 0) {
                exception_handler = &jmploc;
                expandarg(&n, NULL, EXP_QUOTED);
+       } else if (exception_type == EXEXIT) {
+               exitshell();
        }
        exception_handler = savehandler;
        RESTORE_INT(saveint);