From baf4eab8cc0edfc77cce4e74582b23f356364ab9 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 1 Oct 2016 11:59:32 -0700 Subject: [PATCH] Updated SC2126 (markdown) --- SC2126.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SC2126.md b/SC2126.md index 6c89ec5..d435afb 100644 --- a/SC2126.md +++ b/SC2126.md @@ -25,6 +25,8 @@ then fi ``` +Also note that in `foo | grep bar | wc -l`, wc will mask the exit code of grep by default (i.e. without `set -o pipefail`), and always return success. If replacing with `foo | grep -c bar`, grep will exit non-zero when the count is 0. This is convenient for conditional statements but may require handling when used with `set -e`. + ### Exceptions -If you e.g. want to count characters instead of lines, and you actually care about the number and not just whether it's greater than 0. +If you e.g. want to count characters instead of lines, and you actually care about the number and not just whether it's greater than 0, you can [[ignore]] this error.