Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: skip command from debug trap
- X-seq: zsh-workers 25408
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "Peter Stephenson" <pws@xxxxxxx>
- Subject: Re: PATCH: skip command from debug trap
- Date: Wed, 6 Aug 2008 15:09:04 -0400
- Cc: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=1MUOTx4EmfXl6kDRmXK/0mGYTNq6Ce3QBCSWyZXB1z0=; b=pk+mWvLxkJ23l6SX9dI9AEDHBre8YN/7OepfsPOFaZqThEFs/bPcK4OaEkAKsySAni g94wr/USYZgOg/5gXzuDgF8vWbYy5QaR7Gyyk6e4bDdOtdGs7HvXuTgRZm22y0K1LFsk h3qoGX25y+8iHV8SfNA+HcKBE+zVrjvPDYu2M=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=RMutgjYzBBiedqm0ujD8bv+cMft8cvYMhm6PkQZqrmYNVhT9cwvXmRIv8ELJ6oN7Hx QBHOW31UjM6m4V6OHJ62FQobJaFcuSFbVfU0D6OHba5y7tjFfAt6pIvn0V5pKs9b5VCj ad7V2JA77TpxuEf7ckmQ8B76ombr6n03NhjPc=
- In-reply-to: <200808061754.m76HsOQv002657@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <27237.1217946438@xxxxxxx> <6cd6de210808051647k17f14902nce840ca3edd6ddb@xxxxxxxxxxxxxx> <20080806104716.44647a75@news01> <6cd6de210808061000l5c6e0a8fheb06db75560a1598@xxxxxxxxxxxxxx> <200808061754.m76HsOQv002657@xxxxxxxxxxxxxx>
On Wed, Aug 6, 2008 at 1:54 PM, Peter Stephenson <pws@xxxxxxx> 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@xxxxxxx> Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
>
Messages sorted by:
Reverse Date,
Date,
Thread,
Author