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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19034 invoked from network); 5 May 2021 11:07:32 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 May 2021 11:07:32 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1620212852; b=ZtWXBoefjDxxjC/WkZ5G5UAcoCqpXMs04zv+jLy7NujTXqgcF5fCrizBrC4BtP8cfVFRbHlt6F N0k2Tv4dFJBBuuh5h37iSr0bo1feNiYC3KWMcemlSGHdvIuFfwYCPMNC/ezhgwO7zYH+KzWyNi QmHEkZwKzm/6c2lMMkJEpVosFxsdRW6RpR5W8VnfaeC/1UN5zIa9h2pwrFZG7XUTlN0JeB00PU yPZWsq5CYqyGgLWeyzklwjBDjMGaBohYlVsW9f/6DiAc56L5Twrt6ehYBQKkr8/RK6p4icazur q9N4yse5/z36ouDb8zRPFhUzwkYk67JRvrYw1NO7NNbtNg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1620212852; bh=lP/McNYYkNX8wysGq1ULA+dUAqW2LXj3h01aBOQwMXI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date: DKIM-Signature; b=qJMVHIuoj8PBv066SzF4cogQFVVDifX3t0g5pHtGt7a/AJ80n0YUQtlq/yM4L8sj6YrJpJKCtE NWAGs+/uNZ/jP3JMPa5rPWbaJDQgG7fCEjdJ8jhOxjdFA4T5tAHB0266GSMQug7vKmzHxNqRu7 5u61SNEifCwADlVV7kV0tfWRsnEpqJc65DIqsB3RzKw2EvsdtB0uzfHQZF2bnibWuHcBjV0dkD DgqZUq7wGD6Er1WdXdkj9Pgv53aHOQHwo8otOj0cIxnJnFu1U7XdwD8aIuqTludMeooo2O3UJb cMKpZgZv8cIE7+yNDaT7T4EP6DkhTXIlDOOC82ALGevfZw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:Message-ID: Subject:To:From:Date:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=DRTJFNW7p4IwtB7cKgQq+M9UwkmCQ1XriiHy62IRQYI=; b=aOvYqlh4DGzKAvVP6CIYD1WbD8 SWWo/4WQo8Po+BpZpYC9FZisketPoj3tszgyfSoVr+5HEsM0CFX4cTHGG2sSzhK3/dGxqXULHhi/6 mtOYH3M/mUw6H6hlAA7kViDP1JvySOY5FZIMxefpvnN/an1OtPe6/MevmXWnqd8rpZ3IheaVdIdVz hp7c6ZQrAAF5MBq4EsrYhOBENbA86ZKuST0K5ZZU17hJumfn0ZZLFtVHGZBJieKQjy+G416A9SYap 9oZnwDWw9I/NRs9TSSOh0j9OYS4yHoznFKiMFmjXv60eKz9/4bMj9bpqKSKQgxsyf7vKwqSIayuhW oBg+eibg==; Received: from authenticated user by zero.zsh.org with local id 1leFNK-000EE7-Qr; Wed, 05 May 2021 11:07:30 +0000 Authentication-Results: zsh.org; iprev=pass (relay6-d.mail.gandi.net) smtp.remote-ip=217.70.183.198; dmarc=none header.from=chazelas.org; arc=none Received: from relay6-d.mail.gandi.net ([217.70.183.198]:33999) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1leFN5-000Dx8-3t; Wed, 05 May 2021 11:07:15 +0000 X-Originating-IP: 90.215.204.106 Received: from chazelas.org (unknown [90.215.204.106]) (Authenticated sender: stephane@chazelas.org) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 2EC94C0006 for ; Wed, 5 May 2021 11:07:13 +0000 (UTC) Date: Wed, 5 May 2021 12:07:13 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: [bug] wrong exit status upon (e) flag fatal errors in if/while conditions Message-ID: <20210505110713.zmny7625vlmog6ir@chazelas.org> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Seq: 48785 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: $ a='${' zsh -c 'if : ${(e)a}; then echo x; fi; echo y'; echo $? zsh:1: bad substitution 0 $ a='${' zsh -c 'if : ${(e)a}; then echo x; fi; echo y'; echo $? zsh:1: bad substitution 0 That's when the (e) flag is used in the condition part of an "if" or "while" (not "until") statement at least. The shell aborts with an error message but with a success exit status. Also, the description of the X flag suggests that error should be "silently ignored": DOC> X DOC> With this flag, parsing errors occurring with the Q, e and # flags DOC> or the pattern matching forms such as '${NAME#PATTERN}' are DOC> reported. Without the flag, errors are silently ignored. See also: $ a='$(echo ")' zsh -c 'if : ${(Xe)a}; then echo x; fi; echo y'; echo $? zsh:1: unmatched " zsh:1: parse error 0 $ a='$(echo ")' zsh -c 'if : ${(e)a}; then echo x; fi; echo y'; echo $? zsh:1: unmatched " x y 0 Here, the X flag does have an effect, but an error is still reported (even if it doesn't abort the shell) without it. -- Stephane