svn commit: r333011 - head/usr.bin/grep
Baptiste Daroussin
bapt at FreeBSD.org
Wed Apr 25 20:52:18 UTC 2018
Author: bapt
Date: Wed Apr 25 20:52:17 2018
New Revision: 333011
URL: https://svnweb.freebsd.org/changeset/base/333011
Log:
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]
Modified:
head/usr.bin/grep/zgrep.sh
Modified: head/usr.bin/grep/zgrep.sh
==============================================================================
--- head/usr.bin/grep/zgrep.sh Wed Apr 25 19:46:39 2018 (r333010)
+++ head/usr.bin/grep/zgrep.sh Wed Apr 25 20:52:17 2018 (r333011)
@@ -34,7 +34,7 @@ grep_args=""
hyphen=0
silent=0
-prg=$(basename $0)
+prg=${0##*/}
# handle being called 'zegrep' or 'zfgrep'
case ${prg} in
@@ -106,9 +106,8 @@ do
silent=1
shift
;;
- -V)
- ${grep} -V
- exit $?
+ -V|--version)
+ exec ${grep} -V
;;
-*)
grep_args="${grep_args} $1"
@@ -145,9 +144,8 @@ else
if [ ${silent} -lt 1 -a $# -gt 1 ]; then
grep_args="-H ${grep_args}"
fi
- while [ $# -gt 0 ]
- do
- ${cattool} ${catargs} -- "$1" | ${grep} --label="${1}" ${grep_args} -- "${pattern}" -
+ for file do
+ ${cattool} ${catargs} -- "${file}" | ${grep} --label="${file}" ${grep_args} -- "${pattern}" -
shift
done
fi
More information about the svn-src-head
mailing list