summaryrefslogtreecommitdiffstats
path: root/zgrep.in
diff options
context:
space:
mode:
Diffstat (limited to 'zgrep.in')
-rw-r--r--zgrep.in34
1 files changed, 14 insertions, 20 deletions
diff --git a/zgrep.in b/zgrep.in
index df400c3..3298646 100644
--- a/zgrep.in
+++ b/zgrep.in
@@ -28,7 +28,7 @@ while [ x"$1" != x ] ; do
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 "The supported compressors are bzip2, gzip, lzip and xz."
echo
echo "Zegrep is a shortcut for \"zgrep -E\""
echo "Zfgrep is a shortcut for \"zgrep -F\""
@@ -71,26 +71,23 @@ while [ x"$1" != x ] ; do
-?*)
args="${args} $1" ;;
*)
- if [ ${have_pat} = 0 ]; then args="${args} $1"; have_pat=1
+ if [ ${have_pat} = 0 ] ; then args="${args} $1"; have_pat=1
else break
fi ;;
esac
shift
done
-if [ ${have_pat} = 0 ]; then
+if [ ${have_pat} = 0 ] ; then
echo "$0: Pattern not found; use --help for usage." 1>&2
exit 1
fi
-if [ $# = 0 ]; then
+if [ $# = 0 ] ; then
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" ;;
+ bzip2 | gzip | lzip | xz) prog="${prog_name} -cdfq" ;;
*) prog=cat ;;
esac
{ "${bindir}"zutils -m ${prog_name} ; cat ; } | ${prog} | grep ${args}
@@ -101,30 +98,27 @@ retval=0
for i in "$@" ; do
if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
else
- if [ ! -f "$i" ]; then
- if [ -f "$i.gz" ]; then i="$i.gz"
- elif [ -f "$i.bz2" ]; then i="$i.bz2"
- elif [ -f "$i.lz" ]; then i="$i.lz"
- elif [ -f "$i.xz" ]; then i="$i.xz"
+ if [ ! -f "$i" ] ; then
+ if [ -f "$i.gz" ] ; then i="$i.gz"
+ elif [ -f "$i.bz2" ] ; then i="$i.bz2"
+ elif [ -f "$i.lz" ] ; then i="$i.lz"
+ elif [ -f "$i.xz" ] ; then i="$i.xz"
else
echo "$0: File \"$i\" not found or not a regular file" 1>&2
- if [ ${retval} = 0 ]; then retval=1 ; fi
+ if [ ${retval} = 0 ] ; then retval=1 ; fi
continue
fi
fi
bindir=`echo "$0" | sed -e 's,[^/]*$,,'`
prog_name=`"${bindir}"zutils -t -- "$i"`
case "${prog_name}" in
- gzip) prog="gzip -cdfq" ;;
- bzip2) prog="bzip2 -cdfq" ;;
- lzip) prog="lzip -cdfq" ;;
- xz) prog="xz -cdfq" ;;
+ bzip2 | gzip | lzip | xz) prog="${prog_name} -cdfq" ;;
*) prog=cat ;;
esac
- if [ ${list} = 1 ]; then
+ if [ ${list} = 1 ] ; then
${prog} -- "$i" | grep ${args} 2>&1 > /dev/null && echo "$i"
r=$?
- elif [ $# = 1 ] || [ ${no_name} = 1 ]; then
+ elif [ $# = 1 ] || [ ${no_name} = 1 ] ; then
${prog} -- "$i" | grep ${args}
r=$?
else