about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-01-09 21:59:31 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-01-09 21:59:31 +0000
commite8b56578db3d971b18d59a5c579ae19b70ec50a1 (patch)
tree746613cf3c5d42d24ebe65cad8bca1b0566f042a /Src
parentde815e3d22be721c09d6f0bc1896207cc3e3827b (diff)
downloadzsh-e8b56578db3d971b18d59a5c579ae19b70ec50a1.tar.gz
zsh-e8b56578db3d971b18d59a5c579ae19b70ec50a1.tar.xz
zsh-e8b56578db3d971b18d59a5c579ae19b70ec50a1.zip
users/11111: add DEBUG_BEFORE_CMD option
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c18
-rw-r--r--Src/options.c1
-rw-r--r--Src/zsh.h1
3 files changed, 19 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index d65c0a91e..487838a25 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -865,6 +865,22 @@ execlist(Estate state, int dont_change_job, int exiting)
      * semi-colon or ampersand (`sublists').               */
     code = *state->pc++;
     while (wc_code(code) == WC_LIST && !breaks && !retflag) {
+	int donedebug;
+	if (sigtrapped[SIGDEBUG] && isset(DEBUGBEFORECMD)) {
+	    exiting = donetrap;
+	    ret = lastval;
+	    dotrap(SIGDEBUG);
+	    lastval = ret;
+	    donetrap = exiting;
+	    noerrexit = oldnoerrexit;
+	    /*
+	     * Only execute the trap once per sublist, even
+	     * if the DEBUGBEFORECMD option changes.
+	     */
+	    donedebug = 1;
+	} else
+	    donedebug = 0;
+
 	ltype = WC_LIST_TYPE(code);
 	csp = cmdsp;
 
@@ -969,7 +985,7 @@ sublist_done:
 
 	noerrexit = oldnoerrexit;
 
-	if (sigtrapped[SIGDEBUG]) {
+	if (sigtrapped[SIGDEBUG] && !isset(DEBUGBEFORECMD) && !donedebug) {
 	    exiting = donetrap;
 	    ret = lastval;
 	    dotrap(SIGDEBUG);
diff --git a/Src/options.c b/Src/options.c
index 821773d2f..d5e5ee552 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -108,6 +108,7 @@ static struct optname optns[] = {
 {{NULL, "cshjunkiequotes",    OPT_EMULATE|OPT_CSH},	 CSHJUNKIEQUOTES},
 {{NULL, "cshnullcmd",	      OPT_EMULATE|OPT_CSH},	 CSHNULLCMD},
 {{NULL, "cshnullglob",	      OPT_EMULATE|OPT_CSH},	 CSHNULLGLOB},
+{{NULL, "debugbeforecmd",     OPT_EMULATE},		 DEBUGBEFORECMD},
 {{NULL, "emacs",	      0},			 EMACSMODE},
 {{NULL, "equals",	      OPT_EMULATE|OPT_ZSH},	 EQUALS},
 {{NULL, "errexit",	      OPT_EMULATE},		 ERREXIT},
diff --git a/Src/zsh.h b/Src/zsh.h
index 2f627a37f..6f70fd0df 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1602,6 +1602,7 @@ enum {
     CSHJUNKIEQUOTES,
     CSHNULLCMD,
     CSHNULLGLOB,
+    DEBUGBEFORECMD,
     EMACSMODE,
     EQUALS,
     ERREXIT,