zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: "Rocky Bernstein" <rocky.bernstein@gmail.com>
Cc: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: Re: DEBUG_CMD_LINE (Was Re: PATCH: skip command from debug trap)
Date: Thu, 7 Aug 2008 09:54:41 +0100	[thread overview]
Message-ID: <20080807095441.3058605d@news01> (raw)
In-Reply-To: <6cd6de210808061419q2a81856cv62969490069e8f3e@mail.gmail.com>

On Wed, 6 Aug 2008 17:19:14 -0400
"Rocky Bernstein" <rocky.bernstein@gmail.com> wrote:
> > (By the way, it wouldn't be too hard, if not completely trivial, to pass
> > down the code about to be executed in a variable, say DEBUG_CMD_LINE, as
> > reconstructed text, i.e. the same sort of format as what you get if you
> > get the shell to output a shell function that's already loaded.  But
> > it's messy enough that I won't unless it's definitely useful.)
> 
> My secret plan was to get the debugger working enough for folks to
> realize this would be useful. In bash the variable $BASH_COMMAND holds
> the command that is up for execution next. It is not the "line"  (as
> suggested in the name DEBUG_CMD_LINE)
> but the last command or statement.

That's not quite how it works in zsh at the moment.  The DEBUG trap is run
at the level of a "sublist", which is anything separated by ;, &, end of
line, or special terminators in certain cases (e.g. end of case markers) so
in your examples

>    [[ -z $FOO ]] && bar || baz
>    temp=x; x=y; y=temp

the sublists are

[[ -z $FOO ]] && bar || baz
tmp=x
x=y
y=temp

and you get one execution of the trap for each group.  So DEBUG_CMD_LINE
would include the whole of each sublist.

Without having looked at it in depth, it sounds is if zsh is being a bit
more structure-based rather than line-based compared with bash.

It would be possible with a bit of fiddling to get the DEBUG trap to happen
at the level of elements of a sublist, i.e. commands separated by && and
||, but I'm not sure if that's worth it.  Beyond that you run into the
hideous complexity of pipelines and I don't think it can be pushed that far
down.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


  reply	other threads:[~2008-08-07  8:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-06 21:19 Rocky Bernstein
2008-08-07  8:54 ` Peter Stephenson [this message]
2008-08-07  9:31   ` Stephane Chazelas
2008-08-07 10:14     ` Peter Stephenson
2008-08-07 10:40       ` Stephane Chazelas
2008-08-07 12:06         ` Peter Stephenson
2008-08-07 13:37           ` Rocky Bernstein
2008-08-07 15:10             ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080807095441.3058605d@news01 \
    --to=pws@csr.com \
    --cc=rocky.bernstein@gmail.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).