With bash, you can allow set -e
to fail a specific command like:
someCommandThatProbablyFails || true
Is there anything for set -u
to allow a specific variable to be unbound?
Specifically I'm doing something like:
if [ -n "${1}" ]; then
SOMEVAR="${1}"
else
SOME_STUFF_TO_DETERMINE_SOMEVAR
fi
In this case, it's "${1}"
that triggers the unbound variable error if nothing was passed into the script from the command line.
You can use an empty string as the default for an unset variable like this:
${POSSIBLY_UNSET_VARIABLE-}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With