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/bash | |
false; echo "false alone: $?" | |
false | head; echo "false piped to head: $?" | |
set -o pipefail | |
false | head; echo "false 'pipefailed' to head: $?" |
Output:
false alone: 1The "take home" message from this is that you should always set the pipefail option. Too bad it is not the default.
false piped to head: 0
false 'pipefailed' to head: 1
Below are links to some other sites on this topic.
No comments:
Post a Comment