This patch to zgrep script fixes a problem with empty pattern: zgrep -n "" file.gz --- /usr/bin/zgrep Wed Nov 20 11:13:29 2002 +++ zgrep Wed Jan 8 11:27:17 2003 @@ -31,6 +31,7 @@ esac pat="" +pat_set=0 after_dash_dash="" files_with_matches=0 files_without_matches=0 @@ -63,15 +64,15 @@ esac;; esac case "$after_dash_dash$1" in - -[ef]) opt="$opt $1"; shift; pat="$1" + -[ef]) opt="$opt $1"; shift; pat="$1"; pat_set=1 if test "$grep" = grep; then # grep is buggy with -e on SVR4 grep=egrep fi;; -[ABCdm])opt="$opt $1 $2"; shift;; --) opt="$opt $1"; after_dash_dash=1;; -*) opt="$opt $1";; - *) if test -z "$pat"; then - pat="$1" + *) if test $pat_set -eq 0; then + pat="$1"; pat_set=1 else break; fi;; @@ -79,7 +80,7 @@ shift done -if test -z "$pat"; then +if test $pat_set -eq 0; then echo "grep through gzip files" 1>&2 echo "usage: $prog [grep_options] pattern [files]" 1>&2 exit 1