I'm used to this style in other languages:
do_something || (log_error; return 1) # do something, and if that fails, log the error and then return 1 no matter what, even if the logging fails.
But I can't seem to find an equivalent in bash. The problem is that the parenthesis work kind of like a function with its own scope, and the return 1 won't have the expected behavior.
This is what I have so far, but it's not perfect:
! do_something && log_error && return 1
The problem with this is that the ! is confusing, and the return 1 depends on the success of the logging.
This one is better, but more verbose:
do_something || (log_error; return 1) || return 1