diff --git a/usr.bin/gzip/zgrep b/usr.bin/gzip/zgrep index 3fc34bf88e0c..1426c2db016e 100755 --- a/usr.bin/gzip/zgrep +++ b/usr.bin/gzip/zgrep @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: zgrep,v 1.5 2006/05/03 16:48:29 yamt Exp $ +# $NetBSD: zgrep,v 1.6 2008/04/27 09:27:55 nakayama Exp $ # # Copyright (c) 2003 Thomas Klausner. # @@ -33,6 +33,7 @@ endofopts=0 pattern_found=0 grep_args="" hyphen=0 +silent=0 prg=$0 @@ -78,6 +79,10 @@ do hyphen=1 shift ;; + -h) + silent=1 + shift + ;; -*) grep_args="${grep_args} $1" shift @@ -110,9 +115,12 @@ then ${zcat} -fq - | ${grep} ${grep_args} -- "${pattern}" - else # ... on all files given on the command line + if [ ${silent} -lt 1 ]; then + grep_args="-H ${grep_args}" + fi while [ $# -gt 0 ] do - ${zcat} -fq -- "$1" | ${grep} -H --label="${1}" ${grep_args} -- "${pattern}" - + ${zcat} -fq -- "$1" | ${grep} --label="${1}" ${grep_args} -- "${pattern}" - shift done fi