mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
xzgrep: Use -e to specify the pattern to grep.
Now we don't need the separate test for adding the -q option as it can be added directly in the two places where it's needed.
This commit is contained in:
parent
bad61b5997
commit
b56729af9f
1 changed files with 4 additions and 8 deletions
|
@ -146,18 +146,14 @@ while test $# -ne 0; do
|
||||||
grep="$grep $option$optarg"
|
grep="$grep $option$optarg"
|
||||||
done
|
done
|
||||||
|
|
||||||
if test $files_with_matches -eq 1 || test $files_without_matches -eq 1; then
|
|
||||||
grep="$grep -q"
|
|
||||||
fi
|
|
||||||
|
|
||||||
eval "set -- $operands "'${1+"$@"}'
|
eval "set -- $operands "'${1+"$@"}'
|
||||||
|
|
||||||
if test $have_pat -eq 0; then
|
if test $have_pat -eq 0; then
|
||||||
case ${1?"Missing pattern; try \`${0##*/} --help' for help"} in
|
case ${1?"Missing pattern; try \`${0##*/} --help' for help"} in
|
||||||
(*\'*)
|
(*\'*)
|
||||||
grep="$grep -- '"$(printf '%sX\n' "$1" | LC_ALL=C sed "$escape");;
|
grep="$grep -e '"$(printf '%sX\n' "$1" | LC_ALL=C sed "$escape");;
|
||||||
(*)
|
(*)
|
||||||
grep="$grep -- '$1'";;
|
grep="$grep -e '$1'";;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
|
@ -184,9 +180,9 @@ for i; do
|
||||||
exec 5>&1
|
exec 5>&1
|
||||||
($uncompress -- "$i" 5>&-; echo $? >&5) 3>&- |
|
($uncompress -- "$i" 5>&-; echo $? >&5) 3>&- |
|
||||||
if test $files_with_matches -eq 1; then
|
if test $files_with_matches -eq 1; then
|
||||||
eval "$grep" && { printf '%s\n' "$i" || exit 2; }
|
eval "$grep -q" && { printf '%s\n' "$i" || exit 2; }
|
||||||
elif test $files_without_matches -eq 1; then
|
elif test $files_without_matches -eq 1; then
|
||||||
eval "$grep" || {
|
eval "$grep -q" || {
|
||||||
r=$?
|
r=$?
|
||||||
if test $r -eq 1; then
|
if test $r -eq 1; then
|
||||||
printf '%s\n' "$i" || r=2
|
printf '%s\n' "$i" || r=2
|
||||||
|
|
Loading…
Reference in a new issue