Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Interrupts and "always" blocks, and another unexpected exception
- X-seq: zsh-workers 50315
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Interrupts and "always" blocks, and another unexpected exception
- Date: Tue, 31 May 2022 15:55:50 -0700
- Archived-at: <https://zsh.org/workers/50315>
- List-id: <zsh-workers.zsh.org>
I was afraid this was a regression in 5.9, but 5.3 has the same
behavior, and in fact so does 4.3.12 (the oldest I can conveniently
test):
% { sleep 10; } always { print -u2 STATUS: $? }
^CSTATUS: 130
% ({ sleep 10; } always { print -u2 STATUS: $? })
^C
%
Note that the always block fails to execute inside the subshell. If
an interrupt doesn't qualify as an "error condition" in the subshell,
shouldn't that also be true at the top level? (I am concerned that
changing that could break a lot of zle widgets.)
Another case:
% { set -e ; false } always { print -u2 done }
%
So errexit isn't an "error condition" either?
The doc does mention that exit or return "outside of any function"
bypasses the always block, but wrapping either of the above in a
function doesn't change their behavior.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author