Skip to content

Instantly share code, notes, and snippets.

@mikel-egana-aranguren
Created March 18, 2014 11:37
Show Gist options
  • Save mikel-egana-aranguren/9618378 to your computer and use it in GitHub Desktop.
Save mikel-egana-aranguren/9618378 to your computer and use it in GitHub Desktop.
# https://bitbucket.org/cmungall/galaxy-obo/src/e29c68304c23628cb474bf4ac5f778c31a456850/tools/shared/errwrap.sh?at=default
#!/bin/bash
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment