diff galaxy-dist/tool-data/shared/errwrap.sh @ 2:977c838e3442 draft default tip

New dir structure, README improved, tests added and RDF merge tool created
author mikel-egana-aranguren <mikel.egana.aranguren@gmail.com>
date Fri, 25 Apr 2014 14:41:12 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/galaxy-dist/tool-data/shared/errwrap.sh	Fri Apr 25 14:41:12 2014 +0200
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Script for gracefully handling errors in galaxy, copied from
+# https://bitbucket.org/cmungall/galaxy-obo
+
+# Some programs send normal info to STDERR, making galaxy think an error has
+# ocurred. This script, developed by Chris Mungall, fixes the problem by capturing
+# the error and only sending it to STDERR if it is really an error, by lloking at
+# the program's exit code
+
+# Temporary storage for STDERR
+TMP_STDERR="/tmp/errwrap-$$.tmp" || exit 1
+
+# Run the program, send STDERR to temporary file
+"$@" 2> $TMP_STDERR
+
+#check program's exit code
+if (( $? ));  then
+	#Program failed, send STDERR to real STDERR
+	cat $TMP_STDERR >&2
+	rm $TMP_STDERR
+	exit 1
+fi
+
+#Program succeeded, delete STDERR file
+rm $TMP_STDERR
+exit 0
\ No newline at end of file