diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-04-17 12:18:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-04-17 14:46:09 -0400 |
commit | 8700e09c4d2ff0a20d5fa3789a6309078bc1ccb6 (patch) | |
tree | e8a520abdf54b8e66cf0b37dfc4cf4a46c24781f /test/lib/common.inc | |
parent | db673811e674dc246fefa432d205f67ef3c56dbc (diff) |
Use `grep &>/dev/null` instead of `grep -q` when operating on piped stdin.
`grep -q` may exit as soon as it finds a match; this is a good optimization
for when the input is a file. However, if the input is the output of
another program, then that other program will receive SIGPIPE, and further
writes will fail. When this happens, it might (bsdtar does) print a
message about a "write error" to stderr. Which is going to confuse and
alarm the user.
I'll add that this is not purely hypothetical--it has happened to me while
running the test suite.
Diffstat (limited to 'test/lib/common.inc')
-rw-r--r-- | test/lib/common.inc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/lib/common.inc b/test/lib/common.inc index 5b06616..83c54bd 100644 --- a/test/lib/common.inc +++ b/test/lib/common.inc @@ -177,7 +177,7 @@ checkAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done @@ -221,7 +221,7 @@ checkPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkg}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkg}" &>/dev/null) \ || fail "${pkg} not in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -247,7 +247,7 @@ checkRemovedPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done } @@ -273,7 +273,7 @@ checkRemovedAnyPackageDB() { for db in "${DBEXT}" "${FILESEXT}"; do for arch in "${ARCH_BUILD[@]}"; do ( [ -r "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" ] \ - && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep -q "${pkgbase}") \ + && bsdtar -xf "${FTP_BASE}/${repo}/os/${arch}/${repo}${db%.tar.*}" -O | grep "${pkgbase}" &>/dev/null) \ && fail "${pkgbase} should not be in ${repo}/os/${arch}/${repo}${db%.tar.*}" done done |