zsh-workers
 help / color / mirror / code / Atom feed
From: "Rocky Bernstein" <rocky.bernstein@gmail.com>
To: zsh-workers@sunsite.dk
Subject: Re: Weird exit caused in a trap DEBUG which sources a file.
Date: Sat, 2 Aug 2008 07:21:43 -0400	[thread overview]
Message-ID: <6cd6de210808020421k78d716a0mc995862eb761ea2@mail.gmail.com> (raw)
In-Reply-To: <200808011531.m71FVIFl028545@news01.csr.com>

Hmm. This brings up a couple of other things to consider.

It may be useful to have some "trap DEBUG" exit codes alter program
flow. For example in bash if "trap DEBUG" returns 2, then if you are
inside a function that does an immediate return from the function
(implementing a gdb "return" command).
It might also be nice to have a "trap DEBUG" exit value which
indicates that the next command is skipped rather than executed.

Of course, this makes more sense when "trap DEBUG" is run before a
statement is executed rather than after, because doing these things
when you don't really know what the next statement is or which
function you are in is like flying blind.

And since I brought up "trap DEBUG" execution order again, at the risk
of beating a dead horse...

I recently asked David Korn about this:

me:  I guess what I was asking is why it originally kicked in afterwards
 rather than before. This one seemingly innocuous thing is one of the
 biggest things that kept writing a serious debugger impossible. (But
 of course as perhaps you may understand, there are others that still
 make it hard.)

David Korn: That was a mistake which is why I changed it.

I also recall suggesting to Chet Ramey that another trap could be
added like "trap DEBUG" if compatibility was at issue. Although I
never got a reply, he too didn't try to keep the previous behavior
which suggests, like David Korn, he thought it just wrong. In neither
case am I aware of any outcry of incompatibility because this behavior
was changed.


On Fri, Aug 1, 2008 at 11:31 AM, Peter Stephenson <pws@csr.com> wrote:
>
> This is because of the way an explicit "return" from a trap works (which
> is documented in the manual).  "return" with non-zero status from a
> shell function forces the parent function to return; "return" with any
> status from a non-function trap forces the immediately surrounding
> function to return.  In other words, the difference is there's an extra
> level of functions in one case which we have to jump over for the
> special return.
>
> --
> 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-02 11:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-31  2:38 Rocky Bernstein
2008-07-31  9:01 ` Peter Stephenson
2008-07-31 10:05   ` Rocky Bernstein
2008-08-01 12:29     ` Rocky Bernstein
2008-08-01 13:37       ` Peter Stephenson
2008-08-01 15:21         ` Rocky Bernstein
2008-08-01 15:31           ` Peter Stephenson
2008-08-02 11:21             ` Rocky Bernstein [this message]
2008-08-03 10:42               ` Peter Stephenson
2008-08-03 11:28                 ` Rocky Bernstein
2008-08-03 11:50                   ` Peter Stephenson
2008-08-05 11:18                     ` Rocky Bernstein

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=6cd6de210808020421k78d716a0mc995862eb761ea2@mail.gmail.com \
    --to=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).