zsh-workers
 help / color / mirror / code / Atom feed
From: "Rocky Bernstein" <rocky.bernstein@gmail.com>
To: "Peter Stephenson" <pws@csr.com>
Cc: "Zsh hackers list" <zsh-workers@sunsite.dk>
Subject: Re: PATCH: skip command from debug trap
Date: Wed, 6 Aug 2008 15:09:04 -0400	[thread overview]
Message-ID: <6cd6de210808061209g30b82612r148e576dbe1941bd@mail.gmail.com> (raw)
In-Reply-To: <200808061754.m76HsOQv002657@news01.csr.com>

On Wed, Aug 6, 2008 at 1:54 PM, Peter Stephenson <pws@csr.com> wrote:
> "Rocky Bernstein" wrote:
>> Others have noted the challenges in adding an option to return. Making
>> the semantics of the return statement already more complicated doesn't
>> seem wise.
>
> However, as I've pointed out I can guarantee to make that compatible
> with the current shell, and at the same time make return work as in
> other shells (apart from the math eval of the numeric argument, which
> would cause an error in other shells anyway) which it doesn't at the
> moment.  Once we have the latter adding an option is trivial.  Adding an
> option to a builtin is about the simplest thing it's possible to do.

Ok. Adding an option to the return builtin is simple, even if there is
no other shell that I know of that currently does this.

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.

For example POSIX 1003.1 specifies that grep returns 1 when no lines
were selected and greater than 1 if there was an error, and for xargs
it says return code 126 means "The utility specified by *utility* was
found but could not be invoked. Seems a bit arbitrary and not
something I am likely to remember past my current need. But I think
someone working with shells is used to the idea that different
functions or commands return numbers indicate certain things.


>
>> A couple other approaches are setting a variable or calling a routine.
>>  For example  "trap_return --skip"  or TRAP_RETURN="skip"
>
> On the other hand, I can't make this compatible with existing versions
> (the standard namespace pollution problem).
>
> I don't like adding a new builtin just for this.
>
> The variable version is doable, we've done similar things before.  You'd
> have to note that it didn't force return from the current environment,
> either the inline trap or TRAPDEBUG.  You'd also have to be prepared for
> the shell to manipulate the variable behind your back, else you'd run
> into problems with having it set on future traps.  It's not disastrous,
> but I'm not convinced this is simpler.  In fact, at the moment it seems
> to me manifestly much more complicated.
>
> --
> 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-06 19:09 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 [this message]
2008-08-06 19:49           ` Peter Stephenson
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=6cd6de210808061209g30b82612r148e576dbe1941bd@mail.gmail.com \
    --to=rocky.bernstein@gmail.com \
    --cc=pws@csr.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).