[arch-projects] [dbscripts] [PATCH 07/11] test/lib/common.inc: use `grep &>/dev/null` instead of `grep -q`.
Luke Shumaker
lukeshu at sbcglobal.net
Sun May 17 23:44:15 UTC 2015
`grep -q` may exit as soon as it finds a match; the program piped in to it
might not be finished writing, and consequently print a message about a
"write error" to stderr.
I'll add that this is not purely hypothetical--it happened to me while
testing.
---
test/lib/common.inc | 8 ++++----
1 file 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
--
2.4.1
More information about the arch-projects
mailing list