From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 7082 invoked from network); 8 Nov 2022 08:05:14 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Nov 2022 08:05:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Subject:Cc:To:From:Date: References:In-Reply-To:Message-Id:Mime-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=SkdaBDOYCf5nG8U1Q5KdnMPq3GzslmI4MkXz7fFjSC0=; b=FwZvatCDul36HyLGGAovyj4H+V EI37FRTbOD7H2mL3mmHd34gTbenbkDKI6yjJtQjPzS+vxpspHxeuKXyRkSSpT4aWlfHZRuusCR+lO K+Jr3U8JGn8YzK6vfwDTVXDUgKNnWAmYqBiGNa4aVuhxwXsnheEjH1ZiAVGXNbZZLFdQhqC86Hbdn YQe9OcSXDsi199LJaQGOPl36urUSl/AQMN74v05q/LcppXFKhk+8K614ipBfXxx2nr02QWsd+D7Sa cgaW2qccv07yhimCxak0OS/mikAorqCNN3ZGTQunJE5bf9t1iRoHLCcvriBxUlOrE5giCLK+VfEbW cDQ6ARnw==; Received: by zero.zsh.org with local id 1osJbc-000AFY-Pr; Tue, 08 Nov 2022 08:05:12 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1osJb3-0009tz-3Z; Tue, 08 Nov 2022 08:04:37 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id D0A1727C0054; Tue, 8 Nov 2022 03:04:32 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Tue, 08 Nov 2022 03:04:32 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrvdelgdduudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderreejnecuhfhrohhmpefnrgif rhgvnhgtvgcugggvlhojiihquhgviicuoehlrghrrhihvhesiihshhdrohhrgheqnecugg ftrfgrthhtvghrnhepteeggeehuddtheeiueevuefgvdeihfdvieeggeelieduheekgeef heffheeludelnecuffhomhgrihhnpehinhdquhhlmhdruggvnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhmvghsmhhtphgr uhhthhhpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvdejfeekhedqlh grrhhrhihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4B83131A0063; Tue, 8 Nov 2022 03:04:32 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1115-g8b801eadce-fm-20221102.001-g8b801ead Mime-Version: 1.0 Message-Id: <1edb7786-f0b2-4830-88fa-99a19bda39e2@app.fastmail.com> In-Reply-To: References: Date: Tue, 08 Nov 2022 03:04:12 -0500 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Bart Schaefer" , "Philippe Altherr" Cc: zsh-workers@zsh.org Subject: Re: Inconsistent behavior of ERR_EXIT with conditionals Content-Type: text/plain X-Seq: 50913 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Tue, Nov 8, 2022, at 12:36 AM, Bart Schaefer wrote: > So you can see that zsh agrees with bash on your "Failure" cases. The > output of dash (as /bin/sh on ubuntu) is the same as zsh with the > exception of Failure-b, which can't be tested because there is no > equivalent of "declare" (or "local"). Here is a set of tests incorporating most of Philippe's examples (some slightly modified). In the output, "no" and "yes" are intended to indicate whether the shell exited due to "set -e" / ERR_EXIT. The tl;dr is that zsh agrees with other shells, except on three constructs from Philippe's original email. The shells I tested are zsh 5.9, bash 5.1.16(1)-release, ksh AJM 93u+ 2012-08-01, dash 0.5.11.5, and yash 2.52. For more fun, see . % head -n 100 *.sh(n) driver.zsh ==> 1.sh <== f() { { false && true; } } f printf ' no' ==> 2.sh <== f() { false && true } f printf ' no' ==> 3.sh <== f() { if true; then false && true fi } f printf ' no' ==> 4.sh <== f() { case foo in *) false && true ;; esac } f printf ' no' ==> 5.sh <== f() { (false && true) } f printf ' no' ==> 6.sh <== : $(false) printf ' no' ==> 7.sh <== if [ "$KSH_VERSION" ]; then f() { typeset v=$(false); } else f() { local v=$(false); } fi f printf ' no' ==> 8.sh <== if false printf ' no' true then true fi ==> 9.sh <== { false printf ' no' true } && true ==> 10.sh <== false && true printf ' no' ==> 11.sh <== ! true printf ' no' ==> driver.zsh <== set -- *.sh(n) printf ' ' printf ' %5s' $@ echo for sh in zsh bash ksh dash yash; do printf %4s: $sh for arg; do $sh -e $arg || printf ' yes' done echo done % zsh driver.zsh 1.sh 2.sh 3.sh 4.sh 5.sh 6.sh 7.sh 8.sh 9.sh 10.sh 11.sh zsh: no yes no no yes no no no no no no bash: yes yes yes yes yes no no no no no no ksh: yes yes yes yes yes no no no no no no dash: yes yes yes yes yes no no no no no no yash: yes yes yes yes yes no no no no no no > Bash disagrees with dash and > zsh on your "Success" cases, at least at that version. Bash disables "set -e" in command substitutions and has done so since at least 1.14 (the oldest version I can test). Bash 4.4 added an option that causes command substitutions to inherit "set -e", but it remains disabled by default (except in POSIX mode). -- vq