In executing the following line in bash:
set -e
p=$(mktemp -t "${1}.$$.XX")
mktemp fails with this message:
+++ mktemp -t cpfs.c.o.5643.XX
mktemp: too few X's in template `cpfs.c.o.5643.XX'
How can I have the error on fail include errors during command substitutions? Alternatively, how can I propagate the return code form mktemp back such that set -e, or my own code can act on the result?
Return code of last command is always kept in $?.
do something like:
command
ERR=$?
To not to lose that return code for later use.
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