]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
Scripts: Better fix for xzgrep.
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 23 Mar 2011 23:42:49 +0000 (01:42 +0200)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 23 Mar 2011 23:43:23 +0000 (01:43 +0200)
Now it uses "grep -q".

Thanks to Gregory Margo.

src/scripts/xzgrep.in

index 18f780a993e77bb10e9d39a19e42cbe433004a71..a8b8117a0c1004d2b8a657512f1c3ea2191df448 100644 (file)
@@ -126,6 +126,10 @@ while test $# -ne 0; do
   grep="$grep $option$optarg"
 done
 
+if test $files_with_matches -eq 1 || test $files_without_matches -eq 1; then
+  grep="$grep -q"
+fi
+
 eval "set -- $operands "'${1+"$@"}'
 
 if test $have_pat -eq 0; then
@@ -156,9 +160,9 @@ for i; do
     exec 5>&1
     ($uncompress -- "$i" 5>&-; echo $? >&5) 3>&- |
     if test $files_with_matches -eq 1; then
-      eval "$grep" >/dev/null && { printf '%s\n' "$i" || exit 2; }
+      eval "$grep" && { printf '%s\n' "$i" || exit 2; }
     elif test $files_without_matches -eq 1; then
-      eval "$grep" >/dev/null || {
+      eval "$grep" || {
         r=$?
         if test $r -eq 1; then
           printf '%s\n' "$i" || r=2