summaryrefslogtreecommitdiff
path: root/Src/init.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2008-08-07 16:25:14 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2008-08-07 16:25:14 +0000
commit2706eac45492b0fcdfc3cf104ac947e65d09ee25 (patch)
treeff7f6e2a05231a8444589e54c95313114ebcae07 /Src/init.c
parentc4f33330f6797d0c199abf522f79c3ccac88ed55 (diff)
downloadzsh-2706eac45492b0fcdfc3cf104ac947e65d09ee25.tar.gz
zsh-2706eac45492b0fcdfc3cf104ac947e65d09ee25.zip
25415: Make DEBUG_BEFORE_CMD the default.
Reuse ERR_EXIT in DEBUG traps. Clean up trapreturn code.
Diffstat (limited to 'Src/init.c')
-rw-r--r--Src/init.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/Src/init.c b/Src/init.c
index f2dc99af7..d8a0dbc57 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -191,10 +191,6 @@ loop(int toplevel, int justonce)
exit(lastval);
if (((!interact || sourcelevel) && errflag) || retflag)
break;
- if (intrap && trapreturn >= 0) {
- lastval = trapreturn;
- trapreturn = 0;
- }
if (isset(SINGLECOMMAND) && toplevel) {
if (sigtrapped[SIGEXIT])
dotrap(SIGEXIT);
@@ -880,7 +876,8 @@ setupvals(void)
lastmailcheck = time(NULL);
locallevel = sourcelevel = 0;
sfcontext = SFC_NONE;
- trapreturn = 0;
+ trap_return = 0;
+ trap_state = TRAP_STATE_INACTIVE;
noerrexit = -1;
nohistsave = 1;
dirstack = znewlinklist();
@@ -1060,6 +1057,7 @@ source(char *s)
char *old_scriptname = scriptname, *us;
unsigned char *ocs;
int ocsp;
+ int otrap_return = trap_return, otrap_state = trap_state;
if (!s ||
(!(prog = try_source_file((us = unmeta(s)))) &&
@@ -1090,6 +1088,13 @@ source(char *s)
dosetopt(SHINSTDIN, 0, 1);
scriptname = s;
+ /*
+ * The special return behaviour of traps shouldn't
+ * trigger in files sourced from traps; the return
+ * is just a return from the file.
+ */
+ trap_state = TRAP_STATE_INACTIVE;
+
sourcelevel++;
if (prog) {
pushheap();
@@ -1100,6 +1105,9 @@ source(char *s)
loop(0, 0); /* loop through the file to be sourced */
sourcelevel--;
+ trap_state = otrap_state;
+ trap_return = otrap_return;
+
/* restore the current shell state */
if (prog)
freeeprog(prog);