You can write a function that launches and tests the command for you. Assume command1
and command2
are environment variables that have been set to a command.
function mytest {
"$@"
local status=$?
if (( status != 0 )); then
echo "error with $1" >&2
fi
return $status
}
mytest "$command1"
mytest "$command2"