Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
`return` does not behave properly under `!`
- X-seq: zsh-workers 51106
- From: Michael Greenberg <michael@greenberg.science>
- To: zsh-workers@xxxxxxx
- Subject: `return` does not behave properly under `!`
- Date: Tue, 06 Dec 2022 13:18:59 -0500
- Archived-at: <https://zsh.org/workers/51106>
- Feedback-id: ib2794684:Fastmail
- List-id: <zsh-workers.zsh.org>
Following up an example from Harald van Dijk on the dash mailing list, I
discovered that zsh does not `return` properly under a `!`. Here are
four example programs:
```
f() {
while return 5
do
echo fail while1
break
done
}
f
echo $?
g() {
while ! return 6
do
echo fail while2
break
done
}
g
echo $?
h() {
while return 7 && return 8
do
echo fail while3
break
done
}
h
echo $?
i() {
! return 9
echo fail not
}
i
echo $?
```
I would expect the output:
```
5
6
7
9
```
But zsh produces:
```
5
0
7
0
```
The dash shell has a similar bug (no link, since the mailing list
archives aren't up yet), as does yash
<https://osdn.net/projects/yash/ticket/46224>.
Cheers,
Michael
Messages sorted by:
Reverse Date,
Date,
Thread,
Author