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

Re: [PATCH] More ERR_EXIT (was Re: Tests RE behavior of ERR_EXIT)



On Tue, Nov 15, 2022, at 2:18 PM, Philippe Altherr wrote:
> Here is a patch with which all tests pass (the Zsh ones, including the 
> new ones that the patch adds, and my tests mentioned in this thread). 

Here are two additional cases that your patch does not cover.  They
are not regressions, as stable zsh 5.9 is also affected.

As you've mentioned several times, POSIX states:

	If the exit status of a compound command other than a
	subshell command was the result of a failure while -e was
	being ignored, then -e shall not apply to this command.

This implies that ignored non-zero exit statuses may "bubble up"
until reaching a (...) command or a simple command.  You've already
mentioned function calls, but *any* simple command that derives its
exit status from "the last command executed" should be able to
trigger early exit.  At a minimum, this includes the dot/source and
eval commands, neither of which currently behaves correctly.

-----

	% cat /tmp/dotting.sh; echo
	. /tmp/dotted.sh
	echo done

	% cat /tmp/dotted.sh; echo
	if true; then
	    false && true
	fi

	% bash -e /tmp/dotting.sh; echo $?
	1
	% ksh -e /tmp/dotting.sh; echo $?
	1
	% dash -e /tmp/dotting.sh; echo $?
	1
	% yash -e /tmp/dotting.sh; echo $?
	1
	% zsh -e /tmp/dotting.sh; echo $?
	done
	0
	% Src/zsh -e /tmp/dotting.sh; echo $?
	done
	0

-----

	% cat /tmp/eval.sh; echo
	eval 'if true; then false && true; fi'
	echo done

	% bash -e /tmp/eval.sh; echo $?
	1
	% ksh -e /tmp/eval.sh; echo $?
	1
	% dash -e /tmp/eval.sh; echo $?
	1
	% yash -e /tmp/eval.sh; echo $?
	1
	% zsh -e /tmp/eval.sh; echo $?
	done
	0
	% Src/zsh -e /tmp/eval.sh; echo $?
	done
	0

-- 
vq




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