From e83d1023bfe1456a11c682e5980d8c76c227232e Mon Sep 17 00:00:00 2001 From: bapt Date: Wed, 25 Apr 2018 20:52:17 +0000 Subject: [PATCH] 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] --- usr.bin/grep/zgrep.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/usr.bin/grep/zgrep.sh b/usr.bin/grep/zgrep.sh index 347d4ee9f720..1f24ec897914 100755 --- a/usr.bin/grep/zgrep.sh +++ b/usr.bin/grep/zgrep.sh @@ -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