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

Re: errexit and (Z)ERR trap regression



On Fri, Jun 21, 2024, at 2:46 PM, Bart Schaefer wrote:
> Is my recollection incorrect, that there's a change related to this in
> the as-yet-unpublished next revision of POSIX?

There is a change, but it doesn't seem to be relevant here:
https://www.austingroupbugs.net/view.php?id=1150#c4184

The full description of "set -e" in the fresh-out-of-the-oven
POSIX.1-2024 is:

-e	When this option is on, when any command fails (for any of
	the reasons listed in Section 2.8.1 or by returning an exit
	status greater than zero), the shell immediately shall exit,
	as if by executing the `exit' special built-in utility with
	no arguments, with the following exceptions:

	1.	The failure of any individual command in a multi-command
		pipeline, or of any subshell environments in which
		command substitution was performed during word
		expansion, shall not cause the shell to exit.  Only
		the failure of the pipeline itself shall be considered.

	2.	The `-e' setting shall be ignored when executing
		the compound list following the `while', `until',
		`if', or `elif' reserved word, a pipeline beginning
		with the `!' reserved word, or any command of an
		AND-OR list other than the last.

	3.	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 requirement applies to the shell environment and each
	subshell environment separately.  For example, in:

		set -e; (false; echo one) | cat; echo two

	the `false' command causes the subshell to exit without
	executing `echo one'; however, `echo two' is executed because
	the exit status of the pipeline `(false; echo one) | cat'
	is zero.

	In

		set -e; echo $(false; echo one) two

	the `false' command causes the subshell in which the command
	substitution is performed to exit without executing `echo
	one'; the exit status of the subshell is ignored and the
	shell then executes the word-expanded command `echo two'.

-- 
vq




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