1
0
Fork 0

Merging upstream version 0.3.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 04:51:19 +01:00
parent bcca16d621
commit 7777e97ea4
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
11 changed files with 181 additions and 270 deletions

View file

@ -1,3 +1,10 @@
2009-08-?? Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 0.3 released.
* Removed default compressor.
* zcat.in: Do not read data from stdin.
* Updated home page and mailing list addresses.
2009-08-13 Antonio Diaz Diaz <ant_diaz@teleline.es> 2009-08-13 Antonio Diaz Diaz <ant_diaz@teleline.es>
* Version 0.2 released. * Version 0.2 released.

7
configure vendored
View file

@ -7,11 +7,10 @@
# #
# Date of this version: 2009-08-13 # Date of this version: 2009-08-13
invocation_name=$0
args= args=
no_create= no_create=
pkgname=zutils pkgname=zutils
pkgversion=0.2 pkgversion=0.3
srctrigger=zdiff.in srctrigger=zdiff.in
# clear some things potentially inherited from environment. # clear some things potentially inherited from environment.
@ -114,7 +113,7 @@ if [ x"${srcdir}" = x ] ; then
if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=.. ; fi if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=.. ; fi
if [ ! -r ${srcdir}/${srctrigger} ] ; then if [ ! -r ${srcdir}/${srctrigger} ] ; then
## the sed command below emulates the dirname command ## the sed command below emulates the dirname command
srcdir=`echo ${invocation_name} | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` srcdir=`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
fi fi
fi fi
@ -163,7 +162,7 @@ if [ x${no_create} = x ] ; then
# This script is free software: you have unlimited permission # This script is free software: you have unlimited permission
# to copy, distribute and modify it. # to copy, distribute and modify it.
exec /bin/sh ${invocation_name} ${args} --no-create exec /bin/sh $0 ${args} --no-create
EOF EOF
chmod +x config.status chmod +x config.status
fi fi

View file

@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH ZCAT "1" "August 2009" "Zcat 0.2" "User Commands" .TH ZCAT "1" "August 2009" "Zcat 0.3" "User Commands"
.SH NAME .SH NAME
Zcat \- manual page for Zcat 0.2 Zcat \- manual page for Zcat 0.3
.SH SYNOPSIS .SH SYNOPSIS
.B zcat .B zcat
[\fIOPTIONS\fR] [\fICAT_OPTIONS\fR] [\fIFILES\fR] [\fIOPTIONS\fR] [\fICAT_OPTIONS\fR] [\fIFILES\fR]
@ -12,7 +12,7 @@ Zcat is a wrapper script around the cat command that allows
transparent concatenation of any combination of compressed and transparent concatenation of any combination of compressed and
non\-compressed files. If any given file is compressed, its uncompressed non\-compressed files. If any given file is compressed, its uncompressed
content is used. If a given file does not exist, zcat tries the content is used. If a given file does not exist, zcat tries the
compressed file name corresponding to the default compressor selected. compressed file names corresponding to the supported compressors.
The supported compressors are gzip, bzip2, lzip and xz. The supported compressors are gzip, bzip2, lzip and xz.
.PP .PP
CAT_OPTIONS are passed directly to cat. CAT_OPTIONS are passed directly to cat.
@ -24,21 +24,9 @@ display this help and exit
.TP .TP
\fB\-V\fR, \fB\-\-version\fR \fB\-V\fR, \fB\-\-version\fR
output version information and exit output version information and exit
.TP
\fB\-\-gzip\fR
use gzip as default decompressor
.TP
\fB\-\-bzip2\fR
use bzip2 as default decompressor
.TP
\fB\-\-lzip\fR
use lzip as default decompressor (default)
.TP
\fB\-\-xz\fR
use xz as default decompressor
.SH "REPORTING BUGS" .SH "REPORTING BUGS"
Report bugs to lzip\-bug@nongnu.org Report bugs to zutils\-bug@nongnu.org
Lzip home page: http://www.nongnu.org/lzip/lzip.html Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT .SH COPYRIGHT
Copyright \(co 2009 Antonio Diaz Diaz. Copyright \(co 2009 Antonio Diaz Diaz.
This script is free software: you have unlimited permission This script is free software: you have unlimited permission

View file

@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH ZDIFF "1" "August 2009" "Zdiff 0.2" "User Commands" .TH ZDIFF "1" "August 2009" "Zdiff 0.3" "User Commands"
.SH NAME .SH NAME
Zdiff \- manual page for Zdiff 0.2 Zdiff \- manual page for Zdiff 0.3
.SH SYNOPSIS .SH SYNOPSIS
.B zdiff .B zdiff
[\fIOPTIONS\fR] [\fIDIFF_OPTIONS\fR] \fIFILE1 \fR[\fIFILE2\fR] [\fIOPTIONS\fR] [\fIDIFF_OPTIONS\fR] \fIFILE1 \fR[\fIFILE2\fR]
@ -15,9 +15,12 @@ content is used. The supported compressors are gzip, bzip2, lzip and xz.
.PP .PP
Zcmp is a shortcut for "zdiff \fB\-\-cmp\fR" Zcmp is a shortcut for "zdiff \fB\-\-cmp\fR"
.PP .PP
Compares FILE1 to FILE2. If FILE2 is omitted, compares FILE1 to the Compares FILE1 to FILE2. If FILE2 is omitted and FILE1 is compressed,
uncompressed contents of FILE1.[gz|bz2|lz] (depending on the default compares FILE1 to the file with the corresponding decompressed file
compressor selected). DIFF_OPTIONS are passed directly to diff or cmp. name (removes the extension from FILE1). If FILE2 is omitted and FILE1
is not compressed, compares FILE1 to the uncompressed contents of
FILE1.[gz|bz2|lz|xz] (the first one that is found).
DIFF_OPTIONS are passed directly to diff or cmp.
The exit status from diff or cmp is preserved. The exit status from diff or cmp is preserved.
.SH OPTIONS .SH OPTIONS
.TP .TP
@ -27,26 +30,14 @@ display this help and exit
\fB\-V\fR, \fB\-\-version\fR \fB\-V\fR, \fB\-\-version\fR
output version information and exit output version information and exit
.TP .TP
\fB\-\-gzip\fR
use gzip as default decompressor
.TP
\fB\-\-bzip2\fR
use bzip2 as default decompressor
.TP
\fB\-\-lzip\fR
use lzip as default decompressor (default)
.TP
\fB\-\-xz\fR
use xz as default decompressor
.TP
\fB\-\-diff\fR \fB\-\-diff\fR
use diff to compare files (default) use diff to compare files (default)
.TP .TP
\fB\-\-cmp\fR \fB\-\-cmp\fR
use cmp to compare files use cmp to compare files
.SH "REPORTING BUGS" .SH "REPORTING BUGS"
Report bugs to lzip\-bug@nongnu.org Report bugs to zutils\-bug@nongnu.org
Lzip home page: http://www.nongnu.org/lzip/lzip.html Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT .SH COPYRIGHT
Copyright \(co 2009 Antonio Diaz Diaz. Copyright \(co 2009 Antonio Diaz Diaz.
This script is free software: you have unlimited permission This script is free software: you have unlimited permission

View file

@ -1,7 +1,7 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36. .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
.TH ZGREP "1" "August 2009" "Zgrep 0.2" "User Commands" .TH ZGREP "1" "August 2009" "Zgrep 0.3" "User Commands"
.SH NAME .SH NAME
Zgrep \- manual page for Zgrep 0.2 Zgrep \- manual page for Zgrep 0.3
.SH SYNOPSIS .SH SYNOPSIS
.B zgrep .B zgrep
[\fIOPTIONS\fR] [\fIGREP_OPTIONS\fR] \fIPATTERN \fR[\fIFILES\fR] [\fIOPTIONS\fR] [\fIGREP_OPTIONS\fR] \fIPATTERN \fR[\fIFILES\fR]
@ -12,8 +12,8 @@ Zgrep is a wrapper script around the grep command that allows
transparent search on any combination of compressed and non\-compressed transparent search on any combination of compressed and non\-compressed
files. If any given file is compressed, its uncompressed content is files. If any given file is compressed, its uncompressed content is
used. If a given file does not exist, zgrep tries the compressed file used. If a given file does not exist, zgrep tries the compressed file
name corresponding to the default compressor selected. The supported names corresponding to the supported compressors.
compressors are gzip, bzip2, lzip and xz. The supported compressors are gzip, bzip2, lzip and xz.
.PP .PP
GREP_OPTIONS are passed directly to grep. GREP_OPTIONS are passed directly to grep.
The exit status from grep is preserved. The exit status from grep is preserved.
@ -24,21 +24,9 @@ display this help and exit
.TP .TP
\fB\-V\fR, \fB\-\-version\fR \fB\-V\fR, \fB\-\-version\fR
output version information and exit output version information and exit
.TP
\fB\-\-gzip\fR
use gzip as default decompressor
.TP
\fB\-\-bzip2\fR
use bzip2 as default decompressor
.TP
\fB\-\-lzip\fR
use lzip as default decompressor (default)
.TP
\fB\-\-xz\fR
use xz as default decompressor
.SH "REPORTING BUGS" .SH "REPORTING BUGS"
Report bugs to lzip\-bug@nongnu.org Report bugs to zutils\-bug@nongnu.org
Lzip home page: http://www.nongnu.org/lzip/lzip.html Zutils home page: http://www.nongnu.org/zutils/zutils.html
.SH COPYRIGHT .SH COPYRIGHT
Copyright \(co 2009 Antonio Diaz Diaz. Copyright \(co 2009 Antonio Diaz Diaz.
This script is free software: you have unlimited permission This script is free software: you have unlimited permission

Binary file not shown.

View file

@ -65,9 +65,9 @@ The currently provided utilities are zcat, zcmp, zdiff and zgrep.
Zcat is a wrapper script around the cat command that allows transparent Zcat is a wrapper script around the cat command that allows transparent
concatenation of any combination of compressed and non-compressed files. concatenation of any combination of compressed and non-compressed files.
If any given file is compressed, its uncompressed content is used. If a If any given file is compressed, its uncompressed content is used. If a
given file does not exist, zcat tries the compressed file name given file does not exist, zcat tries the compressed file names
corresponding to the default compressor selected. The supported corresponding to the supported compressors. The supported compressors
compressors are gzip, bzip2, lzip and xz. are gzip, bzip2, lzip and xz.
The format for running zcat is: The format for running zcat is:
@ -90,18 +90,6 @@ Print an informative help message describing the options and exit.
@itemx -V @itemx -V
Print the version number of zcat on the standard output and exit. Print the version number of zcat on the standard output and exit.
@item --gzip
Use gzip as default decompressor.
@item --bzip2
Use bzip2 as default decompressor.
@item --lzip
Use lzip as default decompressor (default).
@item --xz
Use xz as default decompressor.
@end table @end table
@ -125,11 +113,14 @@ zdiff [@var{options}] [@var{diff_options}] @var{file1} [@var{file2}]
@end example @end example
@noindent @noindent
Compares @var{file1} to @var{file2}. If @var{file2} is omitted, compares Compares @var{file1} to @var{file2}. If @var{file2} is omitted and
@var{file1} to the uncompressed contents of @var{file1}.[gz|bz2|lz] @var{file1} is compressed, compares @var{file1} to the file with the
(depending on the default compressor selected). @var{diff_options} are corresponding decompressed file name (removes the extension from
passed directly to diff or cmp. The exit status from diff or cmp is @var{file1}). If @var{file2} is omitted and @var{file1} is not
preserved. compressed, compares @var{file1} to the uncompressed contents of
@var{file1}.[gz|bz2|lz|xz] (the first one that is found).
@var{diff_options} are passed directly to diff or cmp. The exit status
from diff or cmp is preserved.
Zdiff supports the following options: Zdiff supports the following options:
@ -142,18 +133,6 @@ Print an informative help message describing the options and exit.
@itemx -V @itemx -V
Print the version number of zdiff on the standard output and exit. Print the version number of zdiff on the standard output and exit.
@item --gzip
Use gzip as default decompressor.
@item --bzip2
Use bzip2 as default decompressor.
@item --lzip
Use lzip as default decompressor (default).
@item --xz
Use xz as default decompressor.
@item --diff @item --diff
Use diff to compare files (default). Use diff to compare files (default).
@ -174,7 +153,7 @@ Zgrep is a wrapper script around the grep command that allows
transparent search on any combination of compressed and non-compressed transparent search on any combination of compressed and non-compressed
files. If any given file is compressed, its uncompressed content is files. If any given file is compressed, its uncompressed content is
used. If a given file does not exist, zgrep tries the compressed file used. If a given file does not exist, zgrep tries the compressed file
name corresponding to the default compressor selected. The supported names corresponding to the supported compressors. The supported
compressors are gzip, bzip2, lzip and xz. compressors are gzip, bzip2, lzip and xz.
The format for running zgrep is: The format for running zgrep is:
@ -198,18 +177,6 @@ Print an informative help message describing the options and exit.
@itemx -V @itemx -V
Print the version number of zgrep on the standard output and exit. Print the version number of zgrep on the standard output and exit.
@item --gzip
Use gzip as default decompressor.
@item --bzip2
Use bzip2 as default decompressor.
@item --lzip
Use lzip as default decompressor (default).
@item --xz
Use xz as default decompressor.
@end table @end table
@ -224,7 +191,7 @@ you don't, no one will ever know about them and they will remain unfixed
for all eternity, if not longer. for all eternity, if not longer.
If you find a bug in zutils, please send electronic mail to If you find a bug in zutils, please send electronic mail to
@email{lzip-bug@@nongnu.org}. Include the version number, which you can @email{zutils-bug@@nongnu.org}. Include the version number, which you can
find by running @w{@samp{zdiff --version}}. find by running @w{@samp{zdiff --version}}.

View file

@ -45,11 +45,24 @@ for i in ${extensions}; do
echo -n . echo -n .
done done
"${ZCAT}" in > copy || fail=1
cmp in copy || fail=1
echo -n .
"${ZCAT}" in in.gz in.bz2 in.lz -- -in- > copy5 || fail=1 "${ZCAT}" in in.gz in.bz2 in.lz -- -in- > copy5 || fail=1
cmp in5 copy5 || fail=1 cmp in5 copy5 || fail=1
echo -n . echo -n .
for i in ${extensions}; do
"${ZDIFF}" --cmp in.$i || fail=1
echo -n .
"${ZDIFF}" --cmp in in.$i || fail=1
echo -n .
"${ZDIFF}" --cmp in.$i in || fail=1
echo -n .
done
for i in ${extensions}; do for i in ${extensions}; do
"${ZDIFF}" in.$i || fail=1 "${ZDIFF}" in.$i || fail=1
echo -n . echo -n .
@ -81,27 +94,23 @@ echo -n .
echo -n . echo -n .
for i in ${extensions}; do
"${ZDIFF}" --cmp in.$i || fail=1
echo -n .
"${ZDIFF}" --cmp in in.$i || fail=1
echo -n .
"${ZDIFF}" --cmp in.$i in || fail=1
echo -n .
done
for i in ${extensions}; do for i in ${extensions}; do
"${ZGREP}" License in.$i 2>&1 > /dev/null || fail=1 "${ZGREP}" License in.$i 2>&1 > /dev/null || fail=1
echo -n . echo -n .
done done
"${ZGREP}" License in 2>&1 > /dev/null || fail=1
echo -n .
"${ZGREP}" License -- -in- 2>&1 > /dev/null || fail=1
echo -n .
"${ZGREP}" License -- -in-.lz 2>&1 > /dev/null || fail=1
echo -n .
"${ZGREP}" License in in.gz in.bz2 in.lz -- -in- 2>&1 > /dev/null || fail=1 "${ZGREP}" License in in.gz in.bz2 in.lz -- -in- 2>&1 > /dev/null || fail=1
echo -n . echo -n .
echo echo
if test ${fail} = 0; then if [ ${fail} = 0 ]; then
echo "tests completed successfully." echo "tests completed successfully."
cd "${objdir}" && rm -r tmp cd "${objdir}" && rm -r tmp
else else

85
zcat.in
View file

@ -7,11 +7,10 @@
LC_ALL=C LC_ALL=C
export LC_ALL export LC_ALL
invocation_name=$0
args= args=
default_prog=lzip two_hyphens=0
# Loop over args until pattern is found # Loop over args until a filename is found
while [ x"$1" != x ] ; do while [ x"$1" != x ] ; do
case "$1" in case "$1" in
@ -22,10 +21,10 @@ while [ x"$1" != x ] ; do
echo "transparent concatenation of any combination of compressed and" echo "transparent concatenation of any combination of compressed and"
echo "non-compressed files. If any given file is compressed, its uncompressed" echo "non-compressed files. If any given file is compressed, its uncompressed"
echo "content is used. If a given file does not exist, zcat tries the" echo "content is used. If a given file does not exist, zcat tries the"
echo "compressed file name corresponding to the default compressor selected." echo "compressed file names corresponding to the supported compressors."
echo "The supported compressors are gzip, bzip2, lzip and xz." echo "The supported compressors are gzip, bzip2, lzip and xz."
echo echo
echo "Usage: ${invocation_name} [OPTIONS] [CAT_OPTIONS] [FILES]" echo "Usage: $0 [OPTIONS] [CAT_OPTIONS] [FILES]"
echo echo
echo "CAT_OPTIONS are passed directly to cat." echo "CAT_OPTIONS are passed directly to cat."
echo "The exit status from cat is preserved." echo "The exit status from cat is preserved."
@ -33,13 +32,9 @@ while [ x"$1" != x ] ; do
echo "Options:" echo "Options:"
echo " -h, --help display this help and exit" echo " -h, --help display this help and exit"
echo " -V, --version output version information and exit" echo " -V, --version output version information and exit"
echo " --gzip use gzip as default decompressor"
echo " --bzip2 use bzip2 as default decompressor"
echo " --lzip use lzip as default decompressor (default)"
echo " --xz use xz as default decompressor"
echo echo
echo "Report bugs to lzip-bug@nongnu.org" echo "Report bugs to zutils-bug@nongnu.org"
echo "Lzip home page: http://www.nongnu.org/lzip/lzip.html" echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html"
exit 0 ;; exit 0 ;;
--version | --ve* | -V) --version | --ve* | -V)
echo "Zcat VERSION" echo "Zcat VERSION"
@ -47,18 +42,10 @@ while [ x"$1" != x ] ; do
echo "This script is free software: you have unlimited permission" echo "This script is free software: you have unlimited permission"
echo "to copy, distribute and modify it." echo "to copy, distribute and modify it."
exit 0 ;; exit 0 ;;
--gz*)
default_prog=gzip ;;
--bz*)
default_prog=bzip2 ;;
--lz*)
default_prog=lzip ;;
--xz*)
default_prog=xz ;;
-) -)
;; ;;
--) --)
shift; break ;; shift ; two_hyphens=1 ; break ;;
-?*) -?*)
args="${args} $1" ;; args="${args} $1" ;;
*) *)
@ -67,41 +54,37 @@ while [ x"$1" != x ] ; do
shift shift
done done
if test $# -eq 0; then
${default_prog} -cd | cat ${args}
exit $?
fi
retval=0 retval=0
for i in "$@" ; do for i in "$@" ; do
prog="${default_prog} -cdfq" if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
case "$i" in else
*.gz | *.tgz) if [ -f "$i" ]; then
prog="gzip -cdfq" ;; case "$i" in
*.bz2 | *.tbz | *.tbz2) *.gz | *.tgz)
prog="bzip2 -cdfq" ;; prog="gzip -cdfq" ;;
*.lz | *.tlz) *.bz2 | *.tbz | *.tbz2)
prog="lzip -cdfq" ;; prog="bzip2 -cdfq" ;;
*.xz | *.txz) *.lz | *.tlz)
prog="xz -cdfq" ;; prog="lzip -cdfq" ;;
*) *.xz | *.txz)
if test -f "$i"; then prog=cat prog="xz -cdfq" ;;
else *)
case ${default_prog} in prog=cat ;;
gzip)
if test -f "$i.gz"; then i="$i.gz"; fi ;;
bzip2)
if test -f "$i.bz2"; then i="$i.bz2"; fi ;;
lzip)
if test -f "$i.lz"; then i="$i.lz"; fi ;;
xz)
if test -f "$i.xz"; then i="$i.xz"; fi ;;
esac esac
fi ;; elif [ -f "$i.gz" ]; then i="$i.gz" ; prog="gzip -cdfq"
esac elif [ -f "$i.bz2" ]; then i="$i.bz2" ; prog="bzip2 -cdfq"
${prog} -- "$i" | cat ${args} elif [ -f "$i.lz" ]; then i="$i.lz" ; prog="lzip -cdfq"
r=$? elif [ -f "$i.xz" ]; then i="$i.xz" ; prog="xz -cdfq"
test "$r" -ne 0 && retval="$r" else
echo "$0: File \"$i\" not found or not a regular file" 1>&2
if [ ${retval} = 0 ]; then retval=1 ; fi
continue
fi
${prog} -- "$i" | cat ${args}
r=$?
if [ $r != 0 ]; then retval=$r ; fi
fi
done done
exit ${retval} exit ${retval}

View file

@ -7,12 +7,11 @@
LC_ALL=C LC_ALL=C
export LC_ALL export LC_ALL
invocation_name=$0
args= args=
default_ext=.lz
diff_prog=diff diff_prog=diff
file1= file1=
file2= file2=
two_hyphens=0
# Loop over args # Loop over args
while [ x"$1" != x ] ; do while [ x"$1" != x ] ; do
@ -28,25 +27,24 @@ while [ x"$1" != x ] ; do
echo echo
echo "Zcmp is a shortcut for \"zdiff --cmp\"" echo "Zcmp is a shortcut for \"zdiff --cmp\""
echo echo
echo "Usage: ${invocation_name} [OPTIONS] [DIFF_OPTIONS] FILE1 [FILE2]" echo "Usage: $0 [OPTIONS] [DIFF_OPTIONS] FILE1 [FILE2]"
echo echo
echo "Compares FILE1 to FILE2. If FILE2 is omitted, compares FILE1 to the" echo "Compares FILE1 to FILE2. If FILE2 is omitted and FILE1 is compressed,"
echo "uncompressed contents of FILE1.[gz|bz2|lz] (depending on the default" echo "compares FILE1 to the file with the corresponding decompressed file"
echo "compressor selected). DIFF_OPTIONS are passed directly to diff or cmp." echo "name (removes the extension from FILE1). If FILE2 is omitted and FILE1"
echo "is not compressed, compares FILE1 to the uncompressed contents of"
echo "FILE1.[gz|bz2|lz|xz] (the first one that is found)."
echo "DIFF_OPTIONS are passed directly to diff or cmp."
echo "The exit status from diff or cmp is preserved." echo "The exit status from diff or cmp is preserved."
echo echo
echo "Options:" echo "Options:"
echo " -h, --help display this help and exit" echo " -h, --help display this help and exit"
echo " -V, --version output version information and exit" echo " -V, --version output version information and exit"
echo " --gzip use gzip as default decompressor"
echo " --bzip2 use bzip2 as default decompressor"
echo " --lzip use lzip as default decompressor (default)"
echo " --xz use xz as default decompressor"
echo " --diff use diff to compare files (default)" echo " --diff use diff to compare files (default)"
echo " --cmp use cmp to compare files" echo " --cmp use cmp to compare files"
echo echo
echo "Report bugs to lzip-bug@nongnu.org" echo "Report bugs to zutils-bug@nongnu.org"
echo "Lzip home page: http://www.nongnu.org/lzip/lzip.html" echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html"
exit 0 ;; exit 0 ;;
--version | --ve* | -V) --version | --ve* | -V)
echo "Zdiff VERSION" echo "Zdiff VERSION"
@ -54,23 +52,15 @@ while [ x"$1" != x ] ; do
echo "This script is free software: you have unlimited permission" echo "This script is free software: you have unlimited permission"
echo "to copy, distribute and modify it." echo "to copy, distribute and modify it."
exit 0 ;; exit 0 ;;
--gz*)
default_ext=.gz ;;
--bz*)
default_ext=.bz2 ;;
--lz*)
default_ext=.lz ;;
--xz*)
default_prog=xz ;;
--diff) --diff)
diff_prog=diff ;; diff_prog=diff ;;
--cmp) --cmp)
diff_prog=cmp ;; diff_prog=cmp ;;
-) -)
echo "${invocation_name}: reading from stdin not supported" echo "$0: reading from stdin not supported"
exit 1 ;; exit 1 ;;
--) --)
shift; break ;; shift; two_hyphens=1 ; break ;;
-?*) -?*)
args="${args} $1" ;; args="${args} $1" ;;
*) *)
@ -80,30 +70,30 @@ while [ x"$1" != x ] ; do
done done
# Loop over files # Loop over files
while [ x"$1" != x ] ; do for i in "$@" ; do
if [ "$1" != "--" ] ; then if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
if test -f "$1"; then else
if test -z "${file1}"; then file1="$1" if [ -f "$i" ]; then
if [ -z "${file1}" ]; then file1="$i"
else else
if test -z "${file2}"; then file2="$1" if [ -z "${file2}" ]; then file2="$i"
else else
echo "${invocation_name}: Too many files; use --help for usage." 1>&2 echo "$0: Too many files; use --help for usage." 1>&2
fi fi
fi fi
else else
echo "${invocation_name}: File \"$1\" not found or not a regular file" 1>&2 echo "$0: File \"$i\" not found or not a regular file" 1>&2
exit 1 exit 1
fi fi
fi fi
shift
done done
if test -z "${file1}"; then if [ -z "${file1}" ]; then
echo "${invocation_name}: No files given; use --help for usage." 1>&2 echo "$0: No files given; use --help for usage." 1>&2
exit 1 exit 1
fi fi
if test -z "${file2}"; then if [ -z "${file2}" ]; then
case "${file1}" in case "${file1}" in
*.gz) *.gz)
file2=`printf "%s" "${file1}" | sed 's/.gz$//'` ;; file2=`printf "%s" "${file1}" | sed 's/.gz$//'` ;;
@ -124,7 +114,14 @@ if test -z "${file2}"; then
*.txz) *.txz)
file2=`printf "%s" "${file1}" | sed 's/txz$/tar/'` ;; file2=`printf "%s" "${file1}" | sed 's/txz$/tar/'` ;;
*) *)
file2="${file1}${default_ext}" ;; if [ -f "${file1}.gz" ]; then file2="${file1}.gz"
elif [ -f "${file1}.bz2" ]; then file2="${file1}.bz2"
elif [ -f "${file1}.lz" ]; then file2="${file1}.lz"
elif [ -f "${file1}.xz" ]; then file2="${file1}.xz"
else
echo "$0: Compressed version of ${file1} not found; use --help for usage." 1>&2
exit 1
fi ;;
esac esac
fi fi
@ -144,8 +141,8 @@ case "${file2}" in
esac esac
retval=0 retval=0
if test -n "${prog1}"; then if [ -n "${prog1}" ]; then
if test -n "${prog2}"; then if [ -n "${prog2}" ]; then
tmp_file=`mktemp "${TMPDIR:-/tmp}"/zdiff.XXXXXXXXXX` || { tmp_file=`mktemp "${TMPDIR:-/tmp}"/zdiff.XXXXXXXXXX` || {
echo 'cannot create a temporary file' 1>&2 echo 'cannot create a temporary file' 1>&2
exit 1 exit 1
@ -159,7 +156,7 @@ if test -n "${prog1}"; then
retval=$? retval=$?
fi fi
else else
if test -n "${prog2}"; then if [ -n "${prog2}" ]; then
${prog2} -cdfq -- "${file2}" | ${diff_prog} ${args} -- "${file1}" - ${prog2} -cdfq -- "${file2}" | ${diff_prog} ${args} -- "${file1}" -
retval=$? retval=$?
else else

116
zgrep.in
View file

@ -7,12 +7,11 @@
LC_ALL=C LC_ALL=C
export LC_ALL export LC_ALL
invocation_name=$0
args= args=
default_prog=lzip
have_pat=0 have_pat=0
list=0 list=0
no_name=0 no_name=0
two_hyphens=0
# Loop over args until pattern is found # Loop over args until pattern is found
while [ x"$1" != x ] ; do while [ x"$1" != x ] ; do
@ -25,10 +24,10 @@ while [ x"$1" != x ] ; do
echo "transparent search on any combination of compressed and non-compressed" echo "transparent search on any combination of compressed and non-compressed"
echo "files. If any given file is compressed, its uncompressed content is" 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 "used. If a given file does not exist, zgrep tries the compressed file"
echo "name corresponding to the default compressor selected. The supported" echo "names corresponding to the supported compressors."
echo "compressors are gzip, bzip2, lzip and xz." echo "The supported compressors are gzip, bzip2, lzip and xz."
echo echo
echo "Usage: ${invocation_name} [OPTIONS] [GREP_OPTIONS] PATTERN [FILES]" echo "Usage: $0 [OPTIONS] [GREP_OPTIONS] PATTERN [FILES]"
echo echo
echo "GREP_OPTIONS are passed directly to grep." echo "GREP_OPTIONS are passed directly to grep."
echo "The exit status from grep is preserved." echo "The exit status from grep is preserved."
@ -36,13 +35,9 @@ while [ x"$1" != x ] ; do
echo "Options:" echo "Options:"
echo " -h, --help display this help and exit" echo " -h, --help display this help and exit"
echo " -V, --version output version information and exit" echo " -V, --version output version information and exit"
echo " --gzip use gzip as default decompressor"
echo " --bzip2 use bzip2 as default decompressor"
echo " --lzip use lzip as default decompressor (default)"
echo " --xz use xz as default decompressor"
echo echo
echo "Report bugs to lzip-bug@nongnu.org" echo "Report bugs to zutils-bug@nongnu.org"
echo "Lzip home page: http://www.nongnu.org/lzip/lzip.html" echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html"
exit 0 ;; exit 0 ;;
--version | --ve* | -V) --version | --ve* | -V)
echo "Zgrep VERSION" echo "Zgrep VERSION"
@ -50,16 +45,8 @@ while [ x"$1" != x ] ; do
echo "This script is free software: you have unlimited permission" echo "This script is free software: you have unlimited permission"
echo "to copy, distribute and modify it." echo "to copy, distribute and modify it."
exit 0 ;; exit 0 ;;
--gz*)
default_prog=gzip ;;
--bz*)
default_prog=bzip2 ;;
--lz*)
default_prog=lzip ;;
--xz*)
default_prog=xz ;;
-[drRzZ] | --di* | --exc* | --inc* | --nu* | --rec*) -[drRzZ] | --di* | --exc* | --inc* | --nu* | --rec*)
echo "${invocation_name}: option $1 not supported" echo "$0: option $1 not supported"
exit 1 ;; exit 1 ;;
-e?* | -f?* | --file=* | --reg*=*) -e?* | -f?* | --file=* | --reg*=*)
args="${args} $1"; have_pat=1 ;; args="${args} $1"; have_pat=1 ;;
@ -74,69 +61,64 @@ while [ x"$1" != x ] ; do
-h | --no-f*) -h | --no-f*)
args="${args} $1"; no_name=1 ;; args="${args} $1"; no_name=1 ;;
--) --)
break ;; shift ; two_hyphens=1 ; break ;;
-?*) -?*)
args="${args} $1" ;; args="${args} $1" ;;
*) *)
if test ${have_pat} = 0; then args="${args} $1"; have_pat=1 if [ ${have_pat} = 0 ]; then args="${args} $1"; have_pat=1
else break else break
fi ;; fi ;;
esac esac
shift shift
done done
if test ${have_pat} = 0; then if [ ${have_pat} = 0 ]; then
echo "${invocation_name}: Pattern not found; use --help for usage." 1>&2 echo "$0: Pattern not found; use --help for usage." 1>&2
exit 1 exit 1
fi fi
if test $# -eq 0; then
${default_prog} -cdfq | grep ${args}
exit $?
fi
retval=0 retval=0
for i in "$@" ; do for i in "$@" ; do
prog="${default_prog} -cdfq" if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
case "$i" in
*.gz | *.tgz)
prog="gzip -cdfq" ;;
*.bz2 | *.tbz | *.tbz2)
prog="bzip2 -cdfq" ;;
*.lz | *.tlz)
prog="lzip -cdfq" ;;
*.xz | *.txz)
prog="xz -cdfq" ;;
*)
if test -f "$i"; then prog=cat
else
case ${default_prog} in
gzip)
if test -f "$i.gz"; then i="$i.gz"; fi ;;
bzip2)
if test -f "$i.bz2"; then i="$i.bz2"; fi ;;
lzip)
if test -f "$i.lz"; then i="$i.lz"; fi ;;
xz)
if test -f "$i.xz"; then i="$i.xz"; fi ;;
esac
fi ;;
esac
if test ${list} -eq 1; then
${prog} -- "$i" | grep ${args} 2>&1 > /dev/null && echo "$i"
r=$?
elif test $# -eq 1 -o ${no_name} -eq 1; then
${prog} -- "$i" | grep ${args}
r=$?
else else
j=`printf "%s" "$i" | sed 's/\\\\/\\\\\\\\/g'` if [ -f "$i" ]; then
j=`printf "%s" "$j" | sed 's/|/\\\\|/g'` case "$i" in
j=`printf "%s" "$j" | sed 's/&/\\\\&/g'` *.gz | *.tgz)
j=`printf "%s" "$j" | tr '\n' ' '` prog="gzip -cdfq" ;;
${prog} -- "$i" | grep ${args} | sed "s|^|${j}:|" *.bz2 | *.tbz | *.tbz2)
r=$? prog="bzip2 -cdfq" ;;
*.lz | *.tlz)
prog="lzip -cdfq" ;;
*.xz | *.txz)
prog="xz -cdfq" ;;
*)
prog=cat ;;
esac
elif [ -f "$i.gz" ]; then i="$i.gz" ; prog="gzip -cdfq"
elif [ -f "$i.bz2" ]; then i="$i.bz2" ; prog="bzip2 -cdfq"
elif [ -f "$i.lz" ]; then i="$i.lz" ; prog="lzip -cdfq"
elif [ -f "$i.xz" ]; then i="$i.xz" ; prog="xz -cdfq"
else
echo "$0: File \"$i\" not found or not a regular file" 1>&2
if [ ${retval} = 0 ]; then retval=1 ; fi
continue
fi
if [ ${list} = 1 ]; then
${prog} -- "$i" | grep ${args} 2>&1 > /dev/null && echo "$i"
r=$?
elif [ $# = 1 ] || [ ${no_name} = 1 ]; then
${prog} -- "$i" | grep ${args}
r=$?
else
j=`printf "%s" "$i" | sed 's/\\\\/\\\\\\\\/g'`
j=`printf "%s" "$j" | sed 's/|/\\\\|/g'`
j=`printf "%s" "$j" | sed 's/&/\\\\&/g'`
j=`printf "%s" "$j" | tr '\n' ' '`
${prog} -- "$i" | grep ${args} | sed "s|^|${j}:|"
r=$?
fi
[ $r != 0 ] && retval="$r"
fi fi
test "$r" -ne 0 && retval="$r"
done done
exit ${retval} exit ${retval}