Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh Fix an amazing crazy botch (of mine) when expanding p...
details: https://anonhg.NetBSD.org/src/rev/839e51706002
branches: trunk
changeset: 448098:839e51706002
user: kre <kre%NetBSD.org@localhost>
date: Mon Jan 21 14:24:44 2019 +0000
description:
Fix an amazing crazy botch (of mine) when expanding prompt strings
(PS1 etc) which, if the shell were already exiting, and a prompt
were to be expanded (which only really happens if -x is enabled,
and an exit trap is set, so the commands in the trap need PS4
expanded and written, last thing, before the shell exits) the shell
would instead simply exit when it finished expanding PS4 (before
even writing it, or the xtrace output).
There were more conditions required to set up the environment for
this to actually occur (it seems to only happen when the exit trap
is set in a function, called in a command substitution) but that's
unimportant, the code was nonsense.
Problem noticed by Martijn Dekker.
XXX pullup -8
diffstat:
bin/sh/parser.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
diffs (54 lines):
diff -r 8fa019516403 -r 839e51706002 bin/sh/parser.c
--- a/bin/sh/parser.c Mon Jan 21 14:18:59 2019 +0000
+++ b/bin/sh/parser.c Mon Jan 21 14:24:44 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parser.c,v 1.161 2019/01/15 14:17:49 kre Exp $ */
+/* $NetBSD: parser.c,v 1.162 2019/01/21 14:24:44 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95";
#else
-__RCSID("$NetBSD: parser.c,v 1.161 2019/01/15 14:17:49 kre Exp $");
+__RCSID("$NetBSD: parser.c,v 1.162 2019/01/21 14:24:44 kre Exp $");
#endif
#endif /* not lint */
@@ -2484,23 +2484,26 @@
expandarg(&n, NULL, 0);
result = stackblock();
}
- INTOFF;
+ } else {
+ psp.v_current_parser = saveparser;
+ xflag = save_x;
+ popfilesupto(savetopfile);
+ handler = savehandler;
+
+ if (exception == EXEXIT)
+ longjmp(handler->loc, 1);
+ if (exception == EXINT)
+ exraise(SIGINT);
+ return ps;
}
psp.v_current_parser = saveparser;
xflag = save_x;
popfilesupto(savetopfile);
handler = savehandler;
- if (exception == EXEXIT)
- longjmp(handler->loc, 1);
- if (result != NULL) {
- INTON;
- } else {
- if (exception == EXINT)
- exraise(SIGINT);
+ if (result == NULL)
result = ps;
- }
return result;
}
Home |
Main Index |
Thread Index |
Old Index