summaryrefslogtreecommitdiffstats
path: root/zgrep.in
diff options
context:
space:
mode:
Diffstat (limited to 'zgrep.in')
-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