zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Interrupts and "always" blocks, and another unexpected exception
Date: Tue, 31 May 2022 15:55:50 -0700	[thread overview]
Message-ID: <CAH+w=7Z59X+ttpeZ=kpFS76rDXhjKu2q4ZjGdAzBPo_JdtE5Og@mail.gmail.com> (raw)

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.


                 reply	other threads:[~2022-05-31 22:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAH+w=7Z59X+ttpeZ=kpFS76rDXhjKu2q4ZjGdAzBPo_JdtE5Og@mail.gmail.com' \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).