Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Unexpected err_return behavior inside if/else block
- X-seq: zsh-users 23530
- From: Daniel Santana da Silva <daniel@xxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Unexpected err_return behavior inside if/else block
- Date: Sun, 8 Jul 2018 20:17:05 -0300
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=santana-tech.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=rLdvA4fGpWP6aZ8lJW1LfTcshYu7TbpS0ZW9aRKuNwc=; b=oAyP92Szr+3PNd+oktXjkI7OFtlEC4X0JVgC42eUUg2qSAG+iu2Y6KhR0EhiBIn8RV GKKLI9nMUgZPr16WSy6/aSEVMNuNdY4R7U2Pey/hmgCCclkebx/TjzCl+yJWrJ9ciR04 YSiqWxD/NRvFHNK5XA5wWZBXY8Vk1/KSYUpJygriJJZrYqBRBuJQpskTzOQvi5xMiozR +6jh0pAmpsQkVf8wTjx0dhiEf/agXrw5paaeeP510SqhO885cUdRvvDWJHNQUN9s1gaT 7QT1vdalwTvHrYT05XnOfPeE4zqH1xjWBVe1cVIATSMa2iDz5FcVRef9TLZsLZ/2PxR2 HswA==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
The following script outputs "status: 1", where I'd expect the script
to exit right after the called function failed with the `false`
statement:
#!/usr/bin/env zsh
setopt err_return
function { if :; then false; fi }
echo status: $?
But if the function is replaced in the following way, the last line
is never reached (as I expected):
#!/usr/bin/env zsh
setopt err_return
function { true && false }
echo status: $?
It seems that the "err_return" option is not respected by the caller
when the called function is exited from inside an if/else block (and
other blocks too e.g. `repeat 1 { false }` or `for i in 1; { false }`).
Is this the intended behavior, or is it a bug?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author