Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: TRY_BLOCK_ERROR and exit status

On Sun, 23 Nov 2014 11:57:55 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Nov 23,  7:08pm, Mikael Magnusson wrote:
> }
> } % { $(< foo) } always { TRY_BLOCK_ERROR=0 }; echo hello
> } zsh: no such file or directory: foo
> } hello
> } 
> } However, I'm not sure how to
> } make the construct return false when it failed with a fatal error.
> Arguably a fatal error should set both errflag and lastval nonzero, but
> that might require a lot of tiny changes all over the place ... on the
> other hand I think always+TRY_BLOCK_ERROR is the only way lastval can
> still be examined after errflag has been set, so maybe it would suffice
> to handle this there?

Yes, probably.

> What should the value of lastval ($?) be in this circumstance?

The easiest way out is probably to leave it if it's non-zero, else set
it to 1.

Given that "always" isn't all that widely used, changing it to return
the last status of the always block might also work.  However, it
doesn't look necessary to go that far.


Messages sorted by: Reverse Date, Date, Thread, Author