1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-28 15:01:21 +02:00

users/11111: add DEBUG_BEFORE_CMD option

This commit is contained in:
Peter Stephenson 2007-01-09 21:59:31 +00:00
parent de815e3d22
commit e8b56578db
5 changed files with 31 additions and 1 deletions

@ -1,5 +1,9 @@
2007-01-09 Peter Stephenson <p.w.stephenson@ntlworld.com>
* users/11111: Doc/Zsh/options.yo, Src/exec.c, Src/options.c,
Src/zsh.h: add DEBUG_BEFORE_CMD option to run DEBUG traps
before the command instead of after.
* 23098: Src/builtin.c, Test/D07multibyte.ztst: print widths
in printf take account of multibyte characters.

@ -1009,6 +1009,14 @@ on the choice of the output base, nor on the output of bases other than
hexadecimal and octal. Note that these formats will be understood on input
irrespective of the setting of tt(C_BASES).
)
pindex(DEBUG_BEFORE_CMD)
cindex(traps, DEBUG, before or after command)
cindex(DEBUG trap, before or after command)
item(tt(DEBUG_BEFORE_CMD))(
Run the tt(DEBUG) trap before each command; otherwise it is run after
each command. Setting this option mimics the behaviour of ksh 93; with
the option unset the behaviour is that of ksh 88.
)
pindex(ERR_EXIT)
cindex(exit status, trapping)
item(tt(ERR_EXIT) (tt(-e), ksh: tt(-e)))(

@ -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);

@ -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},

@ -1602,6 +1602,7 @@ enum {
CSHJUNKIEQUOTES,
CSHNULLCMD,
CSHNULLGLOB,
DEBUGBEFORECMD,
EMACSMODE,
EQUALS,
ERREXIT,