help / color / mirror / code / Atom feed
From: Zach Riggle <zachriggle@gmail.com>
To: zsh-users@zsh.org
Subject: Use of { try-list } always { always-list } with "set e-"
Date: Sat, 17 Jul 2021 08:03:44 -0500	[thread overview]
Message-ID: <CAMP9c5nKDwnq_FTYB8x=Og=pUfmd5t7aMnkDLs_CAF2JuJ+OAA@mail.gmail.com> (raw)

Hello all!

I'm trying to use the "always" keyword to ensure that some cleanup
happens, even if an error occurs.

Perhaps I'm misunderstanding the intent of this feature, but it seems
that the always-list should be executed, even with "set -e".

set -e
() {
        echo TRY
    } always {
        echo ALWAYS

I know that the always-list is executed if there's a "return" or
"exit" statement in the try-list, but I was hoping to be able to put
in some cleanup in the always-list in the event of an error.

Is there any way to achieve what I'm looking to do?

Zach Riggle

             reply	other threads:[~2021-07-17 13:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17 13:03 Zach Riggle [this message]
2021-07-17 20:07 ` Eric Cook

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:

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

  git send-email \
    --in-reply-to='CAMP9c5nKDwnq_FTYB8x=Og=pUfmd5t7aMnkDLs_CAF2JuJ+OAA@mail.gmail.com' \
    --to=zachriggle@gmail.com \
    --cc=zsh-users@zsh.org \


* 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


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).