Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[BUG] err_exit misbehaviour involving function call inside else
- X-seq: zsh-workers 42126
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [BUG] err_exit misbehaviour involving function call inside else
- Date: Thu, 14 Dec 2017 16:40:12 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=pOTeb5J3fQnEHpXXJCaoYnP4OERG5WxXosYcw9mKKLQ=; b=Jb164EHyZ0v8K6wiGSZeZuQHMtFpiC5djeH3NmA9Q+GWNwzMTG5pa0gkDse1Lufto6 iyn51SOKM65eOFwL83VZkGWXtC0mRxQFYkPIL2evq/PeTtz6bxGX+5zCNy8a8NaP4fvu xTassu/Y4hI5uQSNQXrAPg81OHynfxHQxqBUHNH+3Q5c7q0a7v2EqzNjMKU1nsqiXVIu 1cQjCj93f7FQwXJPNv+KI0N315EGF135yUtl1x4tvK6/9KxJm9Bf+61EkHdLVNEcmL7P YjilGofJ0lkR6aHPSZi7byY8Fj25kP+1T6c2YsIzGWrhPoT5MPcPXCmvv1NtsFbkz02g QQDw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
I'm afraid i have another one.
The following script prints '0' in ksh93, dash, and bash, but '1' in zsh:
fn() { return 1; }
(
set -e
if [ x = y ]; then
fn || :
else
fn || :
fi
:
)
echo $?
It doesn't attempt to execute the `|| :` part at all, just immediately returns
after `fn`.
It seems like it has something to do specifically with calling a function inside
the body of an `else`. If i change `x = y` to `x = x`, then the first `fn || :`
behaves as expected. Or if i change `fn` to `false`, that works too. Or if i
remove the conditional entirely.
Unfortunately i ran up against my inexperience again trying to track it down.
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author