From e8b56578db3d971b18d59a5c579ae19b70ec50a1 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 9 Jan 2007 21:59:31 +0000 Subject: users/11111: add DEBUG_BEFORE_CMD option --- Src/exec.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Src/exec.c') 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); -- cgit 1.4.1