zsh-workers
 help / color / mirror / code / Atom feed
* Yet another errexit bug?
@ 2024-09-20 18:05 Bart Schaefer
  2024-09-20 21:15 ` Lawrence Velázquez
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2024-09-20 18:05 UTC (permalink / raw)
  To: Zsh hackers list

I thought we'd squashed all of these, but:

% ! ( setopt errexit; false; print notreached )
notreached
% print $?
1

Compare bash:

$ ! ( set -e; false; echo notreached; )
$ echo $?
0

Zsh still leaking "noerrexit" into subshells, I guess?

Curiously however, bash (5.0.17):

$ ( set -e; false; echo notreached; ) && echo here
notreached
here

So bash is treating a subshell in AND/OR as different than subshell
preceded by NOT?  Zsh matches bash in the AND case, so maybe zsh's NOT
behavior is actually more consistent?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Yet another errexit bug?
  2024-09-20 18:05 Yet another errexit bug? Bart Schaefer
@ 2024-09-20 21:15 ` Lawrence Velázquez
  2024-10-04  5:36   ` Lawrence Velázquez
  0 siblings, 1 reply; 3+ messages in thread
From: Lawrence Velázquez @ 2024-09-20 21:15 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On Fri, Sep 20, 2024, at 2:05 PM, Bart Schaefer wrote:
> I thought we'd squashed all of these, but:
>
> % ! ( setopt errexit; false; print notreached )
> notreached
> % print $?
> 1
>
> Compare bash:
>
> $ ! ( set -e; false; echo notreached; )
> $ echo $?
> 0
>
> Zsh still leaking "noerrexit" into subshells, I guess?
>
> Curiously however, bash (5.0.17):
>
> $ ( set -e; false; echo notreached; ) && echo here
> notreached
> here
>
> So bash is treating a subshell in AND/OR as different than subshell
> preceded by NOT?  Zsh matches bash in the AND case, so maybe zsh's NOT
> behavior is actually more consistent?

From a quick reread, it seems to me that zsh is satisfying the "!"
requirement of POSIX "set", while bash isn't:

	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.

And these shells agree with zsh:
  - dash 0.5.12
  - ksh93u+ 2012-08-01
  - mksh R59 2020/10/31
  - OpenBSD 7.5 pdksh
  - yash 2.56.1

	% cat /tmp/foo.sh
	! (set -e; false; echo notreached)
	echo "$?"
	% bash /tmp/foo.sh
	0
	% bash --posix /tmp/foo.sh
	0
	% dash /tmp/foo.sh
	notreached
	1
	% ksh /tmp/foo.sh
	notreached
	1
	% mksh /tmp/foo.sh
	notreached
	1
	% oksh /tmp/foo.sh
	notreached
	1
	% yash /tmp/foo.sh
	notreached
	1
	% zsh /tmp/foo.sh 
	notreached
	1

-- 
vq


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Yet another errexit bug?
  2024-09-20 21:15 ` Lawrence Velázquez
@ 2024-10-04  5:36   ` Lawrence Velázquez
  0 siblings, 0 replies; 3+ messages in thread
From: Lawrence Velázquez @ 2024-10-04  5:36 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: zsh-workers

On Fri, Sep 20, 2024, at 5:15 PM, Lawrence Velázquez wrote:
> On Fri, Sep 20, 2024, at 2:05 PM, Bart Schaefer wrote:
>> I thought we'd squashed all of these, but:
>>
>> % ! ( setopt errexit; false; print notreached )
>> notreached
>> % print $?
>> 1
>>
>> Compare bash:
>>
>> $ ! ( set -e; false; echo notreached; )
>> $ echo $?
>> 0
>>
>> Zsh still leaking "noerrexit" into subshells, I guess?
>>
>> Curiously however, bash (5.0.17):
>>
>> $ ( set -e; false; echo notreached; ) && echo here
>> notreached
>> here
>>
>> So bash is treating a subshell in AND/OR as different than subshell
>> preceded by NOT?  Zsh matches bash in the AND case, so maybe zsh's NOT
>> behavior is actually more consistent?
>
> From a quick reread, it seems to me that zsh is satisfying the "!"
> requirement of POSIX "set", while bash isn't:
>
> 	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.

Looks like Chet has fixed this in the latest devel commit [*]:

	% cat /tmp/foo.sh
	! (set -e; false; echo notreached)
	printf '%s\n' "$?" "$BASH_VERSION"
	% bash /tmp/foo.sh
	0
	5.2.32(1)-release
	% ./bash /tmp/foo.sh
	notreached
	1
	5.3.0(10)-beta

[*] https://git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=254081c09767738833cdf161b4bc3feb1a51690a

-- 
vq


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-04  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-20 18:05 Yet another errexit bug? Bart Schaefer
2024-09-20 21:15 ` Lawrence Velázquez
2024-10-04  5:36   ` Lawrence Velázquez

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).