diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 16:12:15 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 16:12:15 +0000 |
commit | 904eea648db33416c7222842a0607f9b7d013656 (patch) | |
tree | 01fb0b1be8eff6e37d50938f8200eac45c97f14a /zgrep.in | |
parent | Adding debian version 0.5-1. (diff) | |
download | zutils-904eea648db33416c7222842a0607f9b7d013656.tar.xz zutils-904eea648db33416c7222842a0607f9b7d013656.zip |
Merging upstream version 0.6.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | zgrep.in | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -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 |