Skip to content

Instantly share code, notes, and snippets.

@donnoman
Forked from jpf/gist:107298
Created May 6, 2009 00:32
Show Gist options
  • Save donnoman/107302 to your computer and use it in GitHub Desktop.
Save donnoman/107302 to your computer and use it in GitHub Desktop.
#!/bin/bash
# How to exit if any command in a bash subshell fails with piping all output
set -o pipefail
(
set -o errexit;
echo -n "T";
# false;
echo -n "e";
# false;
echo -n "s";
false;
echo -n "t";
# false;
) 2>&1 | cat
subshell_rv=$?
echo " "
echo "Returned subshell_rv: $subshell_rv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment