Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Feature Request: Allow skipping zsh statement on return from trap DEBUG
- X-seq: zsh-workers 44871
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Rocky Bernstein <rocky.bernstein@xxxxxxxxx>
- Subject: Re: Feature Request: Allow skipping zsh statement on return from trap DEBUG
- Date: Fri, 25 Oct 2019 18:52:06 +0100
- Cc: zsh-workers@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6WnQIy/fOyxmhbN4XkRwOPfqVMGtmL4ZqIlP/5wYZvs=; b=NKK3jxjG/wiffKVDbMWpDySnPbDFQ61mxyYCGcP127OWoRiO8v44FcPgGfm5s+7Xn2 4BK/QxWgcOdwustJn11ZfG2QC0OVeaX3bl3LVohzwVLIqQ6u5kcjKB2rVfurdn+JA1Gi wxdp2RggjdfHKvjNLvUOdDoDZGNEzA9OKrWGvclXH28xPLTtq3NttAjMAn51poqME3op Cx67VNM7fGDtCUu9tKdtaLUJLak9wEfqwg9OBV3EuK2VH8J0zWVujye9n6SgYqrc2pk+ fKM8uunhYafdharTLfNGQH38m1wzzNn9I8BBl0pDi1DZduXh7QEjYsewclqJ7TArtOmk +Scw==
- In-reply-to: <CANCp2gbJs=hW_Pu1AKAKDwhN_5LpFcVG634TGkpas5VDbg8nWg@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Rocky Bernstein <rocky.bernstein@xxxxxxxxx>, zsh-workers@xxxxxxx
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CANCp2gbJs=hW_Pu1AKAKDwhN_5LpFcVG634TGkpas5VDbg8nWg@mail.gmail.com>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author