0
|
1 #!/bin/sh
|
|
2
|
|
3 # STDERR wrapper - discards STDERR if command execution was OK.
|
|
4
|
|
5 #
|
|
6 # This script executes a given command line,
|
|
7 # while saving the STDERR in a temporary file.
|
|
8 #
|
|
9 # When the command is completed, it checks to see if the exit code was zero.
|
|
10 # if so - the command is assumed to have succeeded - the STDERR file is discarded.
|
|
11 # if not - the command is assumed to have failed, and the STDERR file is dumped to the real STDERR
|
|
12 #
|
|
13 #
|
|
14 # Use this wrapper for tools which insist on writing stuff to STDERR even if they succeeded -
|
|
15 # which throws galaxy off balance.
|
|
16 #
|
|
17 #
|
|
18 # Copyright 2009 (C) by Assaf Gordon
|
|
19 # This file is distributed under the BSD license.
|
|
20
|
|
21 TMPFILE=$(mktemp) || exit 1
|
|
22
|
|
23 "$@" 2> $TMPFILE
|
|
24
|
|
25 EXITCODE=$?
|
|
26 # Exitcode != 0 ?
|
|
27 if [ "$EXITCODE" -ne "0" ]; then
|
|
28 cat $TMPFILE >&2
|
|
29 fi
|
|
30 rm $TMPFILE
|
|
31
|
|
32 exit $EXITCODE
|
|
33
|