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