In an answer to a previous question:
How can I use 'do I have root access?' as a conditional in bash?
The suggestion to \'try to do something and de
Bash depends on exit status so there isn't any try/catch equivalent. But it's still powerful to fit your needs.
For simple cases, you can use
[[ your_test_expression ]] && commands
This is equivalent to
if [[ your_test_expression ]]; then
commands
fi
If uses the "exit status" of [[ ... ]] so actually you can use any command after if. Just make sure your control logic depends on the exit status of the command.
For complicated cases, you still need if or case statements to express your logic.