Here's a #ShellScripting puzzle. Suppose you have a shell script run with the "-e" flag, i.e., it's supposed to exit immediately if a command exits with a non-zero exit status. But there's one particular command you want to capture the exit status of so you can check if it's a particular failure code and ignore it if so. What's the cleanest way to do that?
I ended up using
set +e
command-to-check
ret=$?
set -e
This seems gross. Is there a cleaner way?
#Linux #UNIX #scripting