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

Re: [PATCH] Fix ERR_EXIT behavior in function calls and "always" statements



On Sun, Nov 20, 2022, at 7:43 PM, Bart Schaefer wrote:
> Question for the wider list:  With this patch, anonymous functions
> behave like functions with respect to ERR_EXIT.  This is reasonable,
> but it does mean that
>
> set -e
> { { false && true } } # does not exit
> () { { false && true } } # exits
>
> Are we all OK with this

I am not sure.

On the one hand, it's consistent for anonymous functions to behave
like functions here, as they do in other respects.

On the other hand, this behavior violates the general idea that
complex commands shouldn't cause early exits due to ignored nonzero
exit statuses bubbling up from inside.  While anonymous functions
aren't listed as complex commands in the documentation, they certainly
aren't simple commands.  Function calls pop the bubbles (so to
speak) because they are simple commands, not because there's anything
particularly special about functions.  This suggests that anonymous
functions should *not* behave like normal function calls here.

So yeah, I don't know.


> Frankly I'm
> still not certain that the extra level of { } should matter in the
> function example.

Does it?  These seem to behave identically with Philippe's latest
patches; am I overlooking something?

	% Src/zsh -ec '() { { false && true } }; echo done'; echo $?
	1
	% Src/zsh -ec '() { false && true }; echo done'; echo $? 
	1


-- 
vq




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