From 904eea648db33416c7222842a0607f9b7d013656 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 17:12:15 +0100 Subject: Merging upstream version 0.6. Signed-off-by: Daniel Baumann --- zgrep.in | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'zgrep.in') diff --git a/zgrep.in b/zgrep.in index ab004b7..df400c3 100644 --- a/zgrep.in +++ b/zgrep.in @@ -8,7 +8,6 @@ LC_ALL=C export LC_ALL args= -default_prog=gzip have_pat=0 list=0 no_name=0 @@ -26,8 +25,9 @@ while [ x"$1" != x ] ; do echo "files. If any given file is compressed, its uncompressed content is" echo "used. If a given file does not exist, zgrep tries the compressed file" echo "names corresponding to the supported compressors. If no files are" - echo "specified, the standard input is decompressed using the selected" - echo "compressor and fed to grep." + echo "specified, data is read from standard input, decompressed if needed, and" + echo "fed to grep. Data read from standard input must be of the same type; all" + echo "uncompressed or all compressed with the same compressor." echo "The supported compressors are gzip, bzip2, lzip and xz." echo echo "Zegrep is a shortcut for \"zgrep -E\"" @@ -41,10 +41,6 @@ while [ x"$1" != x ] ; do echo "Options:" echo " -h, --help display this help and exit" echo " -V, --version output version information and exit" - echo " --gzip use gzip as decompressor for stdin (default)" - echo " --bzip2 use bzip2 as decompressor for stdin" - echo " --lzip use lzip as decompressor for stdin" - echo " --xz use xz as decompressor for stdin" echo echo "Report bugs to zutils-bug@nongnu.org" echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html" @@ -55,14 +51,6 @@ while [ x"$1" != x ] ; do echo "This script is free software: you have unlimited permission" echo "to copy, distribute and modify it." exit 0 ;; - --gz*) - default_prog=gzip ;; - --bz*) - default_prog=bzip2 ;; - --lz*) - default_prog=lzip ;; - --xz*) - default_prog=xz ;; -[drRzZ] | --di* | --exc* | --inc* | --nu* | --rec*) echo "$0: option $1 not supported" exit 1 ;; @@ -96,7 +84,16 @@ if [ ${have_pat} = 0 ]; then fi if [ $# = 0 ]; then - ${default_prog} -cdfq | grep ${args} + bindir=`echo "$0" | sed -e 's,[^/]*$,,'` + prog_name=`"${bindir}"zutils -t` + case "${prog_name}" in + gzip) prog="gzip -cdfq" ;; + bzip2) prog="bzip2 -cdfq" ;; + lzip) prog="lzip -cdfq" ;; + xz) prog="xz -cdfq" ;; + *) prog=cat ;; + esac + { "${bindir}"zutils -m ${prog_name} ; cat ; } | ${prog} | grep ${args} exit $? fi -- cgit v1.2.3