summaryrefslogtreecommitdiffstats
path: root/zgrep.in
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 16:11:40 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 16:11:40 +0000
commit1d1dc8b97e1cc23b97c1a8053020ce61a0cd1e84 (patch)
treed8f3bdaa398a4228bda811cc30525e16d29987f2 /zgrep.in
parentAdding debian version 0.4-1. (diff)
downloadzutils-1d1dc8b97e1cc23b97c1a8053020ce61a0cd1e84.tar.xz
zutils-1d1dc8b97e1cc23b97c1a8053020ce61a0cd1e84.zip
Merging upstream version 0.5.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--zgrep.in22
1 files changed, 21 insertions, 1 deletions
diff --git a/zgrep.in b/zgrep.in
index 228cbd9..ab004b7 100644
--- a/zgrep.in
+++ b/zgrep.in
@@ -8,6 +8,7 @@
LC_ALL=C
export LC_ALL
args=
+default_prog=gzip
have_pat=0
list=0
no_name=0
@@ -24,7 +25,9 @@ while [ x"$1" != x ] ; do
echo "transparent search on any combination of compressed and non-compressed"
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."
+ 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 "The supported compressors are gzip, bzip2, lzip and xz."
echo
echo "Zegrep is a shortcut for \"zgrep -E\""
@@ -38,6 +41,10 @@ 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"
@@ -48,6 +55,14 @@ 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 ;;
@@ -80,6 +95,11 @@ if [ ${have_pat} = 0 ]; then
exit 1
fi
+if [ $# = 0 ]; then
+ ${default_prog} -cdfq | grep ${args}
+ exit $?
+fi
+
retval=0
for i in "$@" ; do
if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1