Skip to content

Instantly share code, notes, and snippets.

@tlunter
Created November 2, 2014 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tlunter/408dbac860e883156d82 to your computer and use it in GitHub Desktop.
Save tlunter/408dbac860e883156d82 to your computer and use it in GitHub Desktop.
The output of $test changes whether or not the bash grouping is piped into another command or not.
#!/bin/bash
set -e -o pipefail
test=1
{ echo "test"; echo "test2" && test=0; } | cat > /dev/null
echo "$test"
test=1
{ echo "test"; echo "test2" && test=0; } > /dev/null
echo "$test"
# $ ./test.sh
# 1
# 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment