zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: Re: PATCH: skip command from debug trap
Date: Wed, 06 Aug 2008 20:49:01 +0100	[thread overview]
Message-ID: <200808061949.m76Jn10k020995@pws-pc.ntlworld.com> (raw)
In-Reply-To: Message from "Rocky Bernstein" <rocky.bernstein@gmail.com> of "Wed, 06 Aug 2008 15:09:04 EDT." <6cd6de210808061209g30b82612r148e576dbe1941bd@mail.gmail.com>

"Rocky Bernstein" wrote:
> But given the choice of adding
>    1) an option in the return statement everywhere that is specific to
> just "trap DEBUG" or
>    2) specifying what specific numbers do when on a return from "trap DEBUG",
> 
> isn't 2) simpler and more consistent with programming in shell
> languages work? I take it as a given that every function or command is
> going to have error codes that are somewhat arbitrary and that I'm not
> going to intuit.

I'm in two minds about this.  If we didn't have the existing rule that
any non-zero return status from TRAPDEBUG, or any explicit return from
within an inline trap, forced an immediate return, then I'd agree simply
adding to the set of useful statuses was cleaner and more natural.  As
it is, we're now forced to pick some numeric value the user wouldn't
naturally want to return from am enclosing context (since the return
value is propagated).

The option to return seems to me natural enough, because as "return"
means "just return", so "return with an option" means "return but with
slightly different semantics".  Having a different return status meaning
to execute different code (rather than simply provide a different test
for the caller, as normal) is an unusual enough effect that it doesn't
strike me as the unequivocal answer.

But, whatever.  If there's a number we all really like to mean "skip",
we can go with that.  It's already working, is easy to document, and
doesn't need any changes to parsing.

(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.)

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2008-08-06 19:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-05 14:27 Peter Stephenson
2008-08-05 15:50 ` Stephane Chazelas
2008-08-05 23:47 ` Rocky Bernstein
2008-08-06  9:47   ` Peter Stephenson
2008-08-06 14:22     ` Bart Schaefer
2008-08-06 14:30       ` Rocky Bernstein
2008-08-06 14:59       ` Stephane Chazelas
2008-08-06 15:34         ` Peter Stephenson
2008-08-06 17:00     ` Rocky Bernstein
2008-08-06 17:54       ` Peter Stephenson
2008-08-06 19:09         ` Rocky Bernstein
2008-08-06 19:49           ` Peter Stephenson [this message]
2008-08-07  1:00             ` Bart Schaefer
2008-08-07 10:11               ` Peter Stephenson
2008-08-07 14:52                 ` 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=200808061949.m76Jn10k020995@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).