Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
eval and resetting $? (Was Re: trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS)
- X-seq: zsh-workers 25390
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: eval and resetting $? (Was Re: trap DEBUG + set -o DEBUG_BEFORE_CMD not setting $? nonzero in current CVS)
- Date: Mon, 4 Aug 2008 21:33:16 -0400
- 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:mime-version:content-type:content-transfer-encoding :content-disposition; bh=5jymCOPYEqIzK7DBUnajMJ60vo5bNMTO9E3EVENDXkk=; b=ZOdzZF95dL4y/8tn09b83GYkE7ZbpB3CduEHNGU10TrADr8/CMHzCRqzSCFg86CxOw 2ECUs5qYscQJDi4c4eL1OGWcw5g+9SZC0EQIUlOpjq+mDu04Pnx5Jmoa5TmTwn0gjgGo M9l0Y+DlRXvWe61UvZxxV9q3n+QktPGSNM+Cw=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=hMR6aS6v592Co1d3crfUNYkIpEzZyCo7aPFhQ3qyZcEvCm/yR5c07tRuZ1fTh/bdU7 2FnBJSjhnTLYVpdRB8vktGL9T9RRQsasn6j5AC3deySp8OFu35sTDTvxzHww9ZV8Qo3e rYe3h23Tgl6rEFVItYlJdw4hgceekgrCqqVJE=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
Thanks. This seems to work.
However when I use it I run into something else that looks like either
a bug or at least something whose behavior should be documented. In
the following program it feels like $? gets changed/reset? before eval
is run:
#!/usr/local/bin/zsh -f
cmd='print $?'
fdsafsdsfa # Invalid command
eval $cmd # print $? works and so does
# ./file-containing: print $?
print $? works because $? is expanded before print is run. And
sourcing a file which contains the string I want to eval also works,
so this gives me a workaround for this problem.
But somehow I think that a string writing that to a file and sourcing
it should be equivalent to eval'ing the string.
On Mon, Aug 4, 2008 at 1:49 PM, Peter Stephenson <pws@xxxxxxx> wrote:
> On Mon, 4 Aug 2008 06:08:39 -0400
> "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx> wrote:
>> The following code doesn't show $? as nonzero inside trap DEBUG using the
>> CVS source I just downloaded and built.
>>
>> However I don't get this problem on the Ubuntu zsh-beta or zsh.
>> Removing DEBUG_BEFORE_CMD (or I guess having debug run after the
>> command) does set/show $? properly.
>>
>> #!/tmp/zsh/Src/zsh -f
>> #!/src/external-cvs/zsh/Src/zsh -f
>> set -o DEBUG_BEFORE_CMD
>> trap 'print $?' DEBUG
>> fdasfsdafd # invalid command
>> :
>
> Turns out to be unfinished business with the previous patch: that code I
> patched needs also to be told when we're not in a trap at all. It was
> triggering after the trap, resetting the status.
>
> I must write tests for both.
>
> Index: Src/init.c
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Src/init.c,v
> retrieving revision 1.89
> diff -u -r1.89 init.c
> --- Src/init.c 4 Aug 2008 17:32:20 -0000 1.89
> +++ Src/init.c 4 Aug 2008 17:46:26 -0000
> @@ -191,7 +191,7 @@
> exit(lastval);
> if (((!interact || sourcelevel) && errflag) || retflag)
> break;
> - if (trapreturn >= 0) {
> + if (intrap && trapreturn >= 0) {
> lastval = trapreturn;
> trapreturn = 0;
> }
>
>
> --
> 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