Created
July 7, 2020 14:23
-
-
Save mavenraven/8ddf10cbe42ba7d23772ffdebf037ad5 to your computer and use it in GitHub Desktop.
POSIX shell pipefail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
trap 'PIPEFAIL=1' USR1 | |
pipefail() { | |
kill -s USR1 "$$" | |
} | |
false || pipefail | cat | |
echo "$PIPEFAIL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#!/bin/sh
trap 'PIPEFAIL=1' USR1
pipefail() {
kill -s USR1 "$$"
}
false || pipefail | (echo "hi") || pipefail | cat
(exit "$PIPEFAIL") || exit "$PIPEFAIL"