comparison wrapper.sh @ 19:cc270db37d33 draft

Directories re-arranged
author Mikel Egana Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
date Sat, 06 Oct 2012 21:50:39 +0200
parents
children
comparison
equal deleted inserted replaced
18:d3616fac4ca5 19:cc270db37d33
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 writting stuff to STDERR
15 # even if they succeeded -
16 # which throws galaxy off balance.
17 #
18 #
19 # Copyright 2009 (C) by Assaf Gordon
20 # This file is distributed under the BSD license.
21
22 TMPFILE=$(mktemp) || exit 1
23
24 "$@" 2> $TMPFILE
25
26 EXITCODE=$?
27 # Exitcode != 0 ?
28 if [ "$EXITCODE" -ne "0" ]; then
29 cat $TMPFILE >&2
30 fi
31 rm $TMPFILE
32
33 exit $EXITCODE