help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: try/catch in Bash


From: Borden
Subject: Re: try/catch in Bash
Date: Fri, 19 Jun 2026 01:07:46 +0200 (CEST)

I recently discovered the trap builtin, which might help: 
https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-trap

There are fiddly bits that diverge from try/catch block syntax, but probably 
the closest thing in bash. I think you also have to set -E so that subcommands 
inherit your trap: 
https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html

I'd suggest a script if I wasn't still learning this myself.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]