zgrep: small improvements
* Use slightly more efficient method to determine the name of the program called [1] * Use nicer form to loop over arguments [1] * add special support for --version along with -V previously added by kevans Reported by: jilles@ [1]
This commit is contained in:
parent
d2d4831056
commit
e83d1023bf
@ -34,7 +34,7 @@ grep_args=""
|
|||||||
hyphen=0
|
hyphen=0
|
||||||
silent=0
|
silent=0
|
||||||
|
|
||||||
prg=$(basename $0)
|
prg=${0##*/}
|
||||||
|
|
||||||
# handle being called 'zegrep' or 'zfgrep'
|
# handle being called 'zegrep' or 'zfgrep'
|
||||||
case ${prg} in
|
case ${prg} in
|
||||||
@ -106,9 +106,8 @@ do
|
|||||||
silent=1
|
silent=1
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-V)
|
-V|--version)
|
||||||
${grep} -V
|
exec ${grep} -V
|
||||||
exit $?
|
|
||||||
;;
|
;;
|
||||||
-*)
|
-*)
|
||||||
grep_args="${grep_args} $1"
|
grep_args="${grep_args} $1"
|
||||||
@ -145,9 +144,8 @@ else
|
|||||||
if [ ${silent} -lt 1 -a $# -gt 1 ]; then
|
if [ ${silent} -lt 1 -a $# -gt 1 ]; then
|
||||||
grep_args="-H ${grep_args}"
|
grep_args="-H ${grep_args}"
|
||||||
fi
|
fi
|
||||||
while [ $# -gt 0 ]
|
for file do
|
||||||
do
|
${cattool} ${catargs} -- "${file}" | ${grep} --label="${file}" ${grep_args} -- "${pattern}" -
|
||||||
${cattool} ${catargs} -- "$1" | ${grep} --label="${1}" ${grep_args} -- "${pattern}" -
|
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user