3 # redirects standard out and standard error output to temp files and runs all the parameters to this script as a command.
4 # if there is no error, then the files are just deleted.
5 # if there was an error, then the two output file are sent to standard out and standard error.
6 # an additional error message is sent to standard error.
8 # echo "squelch args: $(printf -- "[%s] " "${@}")"
10 newout="$(mktemp /tmp/squelch.out.XXXXXX)"
11 newerr="$(mktemp /tmp/squelch.err.XXXXXX)"
13 eval "${@}" >"$newout" 2>"$newerr"
16 if [ $retval != 0 ]; then
17 # there was an error during the execution of the command.
20 echo "An error was returned during execution of: ${@}" >&2
24 \rm "$newout" "$newerr"
26 # pass along the error code we saw, whether success or failure, so that this command has same
27 # exit result as the original would have.