Skip to content

zsh: support { try-list } always { always-list } #1211

@LangLangBart

Description

@LangLangBart

Extract from the 4.2.0 release notes (released on 19 March 2004):

A new try block and always block syntax has been introduced to make it easier
to ensure the shell runs important tidy-up code in the event of an error. It
also runs after a break, continue, or return, including a return forced by the
ERR_RETURN option (but not an exit, which is immediate). The syntax is:

{ try-block-list } always { always-block-list }

where no newline or semicolon may appear between } and always. [...]

Source: https://zsh.sourceforge.io/releases.html#:~:text=Changes%20since%20zsh%20version%204.2.0

{
  command_that_might_fail
} always {
  echo "This code is always executed."
}

Zsh docs: https://zsh.sourceforge.io/Doc/Release/Shell-Grammar.html#:~:text=try%2Dlist&text=always&text=always%2Dlist

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions