Mercurial > repos > lparsons > cutadapt
comparison discard_stderr_wrapper.sh @ 4:0a872e59164c
Added discard_stderr_wrapper.sh script to catch report and redirect to stdout
author | Lance Parsons <lparsons@princeton.edu> |
---|---|
date | Wed, 25 May 2011 19:33:40 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:7ed26fc9fa8a | 4:0a872e59164c |
---|---|
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 - 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 # Modified by Lance Parsons (2011) | |
22 # Echo STDERR to STDOUT if return code was 0 | |
23 | |
24 TMPFILE=$(mktemp -t tmp.XXXXXXXXXX) || exit 1 | |
25 #CWD=`pwd` | |
26 #DIRECTORY=$(cd `dirname $0` && pwd) | |
27 #cd $DIRECTORY | |
28 "$@" 2> $TMPFILE | |
29 | |
30 EXITCODE=$? | |
31 # Exitcode != 0 ? | |
32 if [ "$EXITCODE" -ne "0" ]; then | |
33 cat $TMPFILE >&2 | |
34 else | |
35 # echo "Testing STDOUT" | |
36 cat $TMPFILE >&1 | |
37 fi | |
38 rm $TMPFILE | |
39 cd $CWD | |
40 exit $EXITCODE |