43 lines
935 B
Diff
43 lines
935 B
Diff
--- zgrep.in
|
|
+++ zgrep.in
|
|
@@ -102,13 +102,36 @@
|
|
fi
|
|
|
|
if test $# -eq 0; then
|
|
- gzip -cdfq | $grep $opt "$pat"
|
|
- exit $?
|
|
+ if type -p dd > /dev/null 2>&1 &&
|
|
+ type -p mimencode > /dev/null 2>&1 &&
|
|
+ type -p file > /dev/null 2>&1
|
|
+ then
|
|
+ uncompress=gzip
|
|
+ x=`dd bs=20 count=1 2> /dev/null | mimencode -b`
|
|
+ case `echo -n $x | mimencode -u -b | file -b -` in
|
|
+ bzip2*)
|
|
+ uncompress=bzip2
|
|
+ ;;
|
|
+ esac
|
|
+ (echo -n $x | mimencode -u -b; cat -) | $uncompress -cdfq | $grep $opt "$pat"
|
|
+ exit $?
|
|
+ else
|
|
+ gzip -cdfq | $grep $opt "$pat"
|
|
+ exit $?
|
|
+ fi
|
|
fi
|
|
|
|
res=0
|
|
for i do
|
|
- gzip -cdfq -- "$i" |
|
|
+ case $i in
|
|
+ *.bz2)
|
|
+ uncompress=bzip2
|
|
+ ;;
|
|
+ *)
|
|
+ uncompress=gzip
|
|
+ ;;
|
|
+ esac
|
|
+ $uncompress -cdfq "$i" |
|
|
if test $files_with_matches -eq 1; then
|
|
$grep $opt "$pat" > /dev/null && printf '%s\n' "$i"
|
|
elif test $files_without_matches -eq 1; then
|