21 April 2011

bash pipefail

If you care about the exit code of a piped bash command, you must set the "pipefail" option. The code below shows this.

false alone: 1
false piped to head: 0
false 'pipefailed' to head: 1
The "take home" message from this is that you should always set the pipefail option. Too bad it is not the default.

Below are links to some other sites on this topic.

No comments:

Post a Comment