From: Lasse Collin Date: Wed, 23 Mar 2011 23:42:49 +0000 (+0200) Subject: Scripts: Better fix for xzgrep. X-Git-Tag: upstream/5.1.3~190 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40277998cb9bad564ce4827aff152e6e1c904dfa;p=platform%2Fupstream%2Fxz.git Scripts: Better fix for xzgrep. Now it uses "grep -q". Thanks to Gregory Margo. --- diff --git a/src/scripts/xzgrep.in b/src/scripts/xzgrep.in index 7ab617b..0024237 100644 --- a/src/scripts/xzgrep.in +++ b/src/scripts/xzgrep.in @@ -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 @@ -157,9 +161,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