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

Re: Question about err_return



On Sun, 20 Aug 2017 22:28:34 -0700
Radon Rosborough <radon.neon@xxxxxxxxx> wrote:
> Hi all,
> 
> I have a question about err_return. Specifically, why does the
> following:
> 
>     function { setopt err_return; false; echo 'oh no' }
> 
> print nothing, while
> 
>     function { setopt err_return; false; echo 'oh no' } && true
> 
> prints 'oh no'? This seems very inconsistent to me, as I would expect
> the result of 'x && true' to be the same as 'x' in all circumstances.

It's probably just a bug that we don't reset the state inside functions.

We did have tests assuming it worked this way, but it's not documented
and not obvious, so I think it makes sense to change it.

I can do this, but I need to be careful about one subtlety: whether
ERR_EXIT is still suppressed in that case.  I think the answer is yes
--- it applies globally rather than hierarchically.  To go with bash, it
would mean (so far as I can see) this applies even if err_exit is
explicitly set in the function --- i.e. suppression of the effect really
is controlled by internal and not user-visible state.

In that case I'll have to do a bit more work separating out the innards
of the two options.

pws



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