zsh: support { try-list } always { always-list }
Author: LangLangBartCreated Oct 22, 2025Updated Sep 7, 2026
Labelszsh
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
}andalways. [...]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."
}Source: mvdan/sh