* Feature Request: Allow skipping zsh statement on return from trap DEBUG @ 2019-10-24 20:17 Rocky Bernstein 2019-10-25 17:52 ` Stephane Chazelas 0 siblings, 1 reply; 3+ messages in thread From: Rocky Bernstein @ 2019-10-24 20:17 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 784 bytes --] A while ago I wrote a debugger for zsh called zshdb <https://zshdb.readthedocs.io/en/latest/>. See also https://repology.org/project/zshdb/versions . A feature that is missing in the debugger and that is available in the corresponding debugger for bash, bashdb, is the skip command. This command skips over the upcoming statement to be executed. The way this works in bashdb, is that if the debug hook returns with a nonzero value. The way BASH works is that if the trap DEBUG hook returns a nonzero value, BASH skips statement to be run. Thoughts about extening zsh so that it too will skip the upcoming statement if the zsh trap DEBUG hook return a non-zero value. Or more generally some means by which a DEBUG hook can indicate to zsh to skip the upcoming statement? Thanks. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Feature Request: Allow skipping zsh statement on return from trap DEBUG 2019-10-24 20:17 Feature Request: Allow skipping zsh statement on return from trap DEBUG Rocky Bernstein @ 2019-10-25 17:52 ` Stephane Chazelas 2019-10-26 1:37 ` Rocky Bernstein 0 siblings, 1 reply; 3+ messages in thread From: Stephane Chazelas @ 2019-10-25 17:52 UTC (permalink / raw) To: Rocky Bernstein; +Cc: zsh-workers 2019-10-24 16:17:27 -0400, Rocky Bernstein: > A while ago I wrote a debugger for zsh called zshdb > <https://zshdb.readthedocs.io/en/latest/>. See also > https://repology.org/project/zshdb/versions . > > A feature that is missing in the debugger and that is available in the > corresponding debugger for bash, bashdb, is the skip command. > > This command skips over the upcoming statement to be executed. The way this > works in bashdb, is that if the debug hook returns with a nonzero value. > The way BASH works is that if the trap DEBUG hook returns a nonzero value, > BASH skips statement to be run. > > Thoughts about extening zsh so that it too will skip the upcoming statement > if the zsh trap DEBUG hook return a non-zero value. Or more generally some > means by which a DEBUG hook can indicate to zsh to skip the upcoming > statement? [...] See info zsh trap: } If SIG is DEBUG then ARG will be executed before each command if } the option DEBUG_BEFORE_CMD is set (as it is by default), else } after each command. Here, a 'command' is what is described as a } 'sublist' in the shell grammar, see *note Simple Commands & } Pipelines::. If DEBUG_BEFORE_CMD is set various additional } features are available. First, it is possible to skip the next } command by setting the option ERR_EXIT; see the description of the } ERR_EXIT option in *note Description of Options::. Also, the shell } parameter ZSH_DEBUG_CMD is set to the string corresponding to the } command to be executed following the trap. Note that this string } is reconstructed from the internal format and may not be formatted } the same way as the original text. The parameter is unset after } the trap is executed. Was added in 2008: https://www.zsh.org/mla/workers/2008/msg01075.html You participated in that discussion, sounds likely you actually requested the feature then. TRAPDEBUG() { echo "$ZSH_DEBUG_CMD" [[ $ZSH_DEBUG_CMD = *x* ]] && set -o errexit } echo x echo y gives: echo x echo y y -- Stephane ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Feature Request: Allow skipping zsh statement on return from trap DEBUG 2019-10-25 17:52 ` Stephane Chazelas @ 2019-10-26 1:37 ` Rocky Bernstein 0 siblings, 0 replies; 3+ messages in thread From: Rocky Bernstein @ 2019-10-26 1:37 UTC (permalink / raw) To: Stephane Chazelas; +Cc: zsh-workers [-- Attachment #1: Type: text/plain, Size: 2771 bytes --] My apologies for not realizing this. I _did_ look at the trap DEBUG command and even noticed the DEBUG_BEFORE_CMD, but I guess I didn't read carefully enough to notice ERR_EXIT. At any rate with commit https://github.com/rocky/zshdb/commit/d3f00505f58ddb3d781a2140d92baa19dcc0a200 (and the one before that) this is now all in the debugger, and it works great! When I get a chance, a new release, 1.1.0, will go out soon with this in it. Thanks, yet again, to Stephane for helping me out here. -- I make mistakes, that's why I work on debuggers. On Fri, Oct 25, 2019 at 1:52 PM Stephane Chazelas < stephane.chazelas@gmail.com> wrote: > 2019-10-24 16:17:27 -0400, Rocky Bernstein: > > A while ago I wrote a debugger for zsh called zshdb > > <https://zshdb.readthedocs.io/en/latest/>. See also > > https://repology.org/project/zshdb/versions . > > > > A feature that is missing in the debugger and that is available in the > > corresponding debugger for bash, bashdb, is the skip command. > > > > This command skips over the upcoming statement to be executed. The way > this > > works in bashdb, is that if the debug hook returns with a nonzero value. > > The way BASH works is that if the trap DEBUG hook returns a nonzero > value, > > BASH skips statement to be run. > > > > Thoughts about extening zsh so that it too will skip the upcoming > statement > > if the zsh trap DEBUG hook return a non-zero value. Or more generally > some > > means by which a DEBUG hook can indicate to zsh to skip the upcoming > > statement? > [...] > > See info zsh trap: > > } If SIG is DEBUG then ARG will be executed before each command if > } the option DEBUG_BEFORE_CMD is set (as it is by default), else > } after each command. Here, a 'command' is what is described as a > } 'sublist' in the shell grammar, see *note Simple Commands & > } Pipelines::. If DEBUG_BEFORE_CMD is set various additional > } features are available. First, it is possible to skip the next > } command by setting the option ERR_EXIT; see the description of the > } ERR_EXIT option in *note Description of Options::. Also, the shell > } parameter ZSH_DEBUG_CMD is set to the string corresponding to the > } command to be executed following the trap. Note that this string > } is reconstructed from the internal format and may not be formatted > } the same way as the original text. The parameter is unset after > } the trap is executed. > > Was added in 2008: https://www.zsh.org/mla/workers/2008/msg01075.html > > You participated in that discussion, sounds likely you actually > requested the feature then. > > TRAPDEBUG() { > echo "$ZSH_DEBUG_CMD" > [[ $ZSH_DEBUG_CMD = *x* ]] && set -o errexit > } > echo x > echo y > > > gives: > > echo x > echo y > y > > -- > Stephane > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-26 1:38 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-10-24 20:17 Feature Request: Allow skipping zsh statement on return from trap DEBUG Rocky Bernstein 2019-10-25 17:52 ` Stephane Chazelas 2019-10-26 1:37 ` Rocky Bernstein
Code repositories for project(s) associated with this public inbox https://git.vuxu.org/mirror/zsh/ This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).