Merging upstream version 0.7.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
7346c77169
commit
7799d0c878
17 changed files with 318 additions and 96 deletions
|
@ -1,3 +1,9 @@
|
|||
2009-10-21 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||
|
||||
* Version 0.7 released.
|
||||
* Added new utility; ztest.
|
||||
* zcat.in: Added new option "--recursive".
|
||||
|
||||
2009-10-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||
|
||||
* Version 0.6 released.
|
||||
|
|
23
Makefile.in
23
Makefile.in
|
@ -8,7 +8,7 @@ INSTALL_DIR = $(INSTALL) -d -m 755
|
|||
SHELL = /bin/sh
|
||||
|
||||
objs = arg_parser.o main.o
|
||||
scripts = zcat zcmp zdiff zegrep zfgrep zgrep
|
||||
scripts = zcat zcmp zdiff zegrep zfgrep zgrep ztest
|
||||
|
||||
|
||||
.PHONY : all install install-info install-man install-strip \
|
||||
|
@ -47,6 +47,10 @@ zgrep : zgrep.in
|
|||
sed -e 's,VERSION,$(progversion),g' $(VPATH)/zgrep.in > zgrep
|
||||
chmod a+x zgrep
|
||||
|
||||
ztest : ztest.in
|
||||
sed -e 's,VERSION,$(progversion),g' $(VPATH)/ztest.in > ztest
|
||||
chmod a+x ztest
|
||||
|
||||
main.o : main.cc
|
||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -DPROGVERSION=\"$(progversion)\" -c -o $@ $<
|
||||
|
||||
|
@ -65,7 +69,8 @@ info : $(VPATH)/doc/$(progname).info
|
|||
$(VPATH)/doc/$(progname).info : $(VPATH)/doc/$(progname).texinfo
|
||||
cd $(VPATH)/doc && makeinfo $(progname).texinfo
|
||||
|
||||
man : $(VPATH)/doc/zcat.1 $(VPATH)/doc/zdiff.1 $(VPATH)/doc/zgrep.1
|
||||
man : $(VPATH)/doc/zcat.1 $(VPATH)/doc/zdiff.1 \
|
||||
$(VPATH)/doc/zgrep.1 $(VPATH)/doc/ztest.1
|
||||
|
||||
$(VPATH)/doc/zcat.1 : zcat
|
||||
help2man -n 'concatenate compressed files to stdout' \
|
||||
|
@ -79,6 +84,10 @@ $(VPATH)/doc/zgrep.1 : zgrep
|
|||
help2man -n 'search compressed files for a regular expression' \
|
||||
-o $(VPATH)/doc/zgrep.1 --no-info ./zgrep
|
||||
|
||||
$(VPATH)/doc/ztest.1 : ztest
|
||||
help2man -n 'verify integrity of compressed files' \
|
||||
-o $(VPATH)/doc/ztest.1 --no-info ./ztest
|
||||
|
||||
Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
|
||||
./config.status
|
||||
|
||||
|
@ -86,7 +95,7 @@ check : all $(VPATH)/testsuite/check.sh
|
|||
@$(VPATH)/testsuite/check.sh $(VPATH)/testsuite
|
||||
|
||||
install : all install-info install-man
|
||||
if test ! -d $(DESTDIR)$(bindir) ; then $(INSTALL_DIR) $(DESTDIR)$(bindir) ; fi
|
||||
if [ ! -d $(DESTDIR)$(bindir) ] ; then $(INSTALL_DIR) $(DESTDIR)$(bindir) ; fi
|
||||
$(INSTALL_PROGRAM) ./$(progname) $(DESTDIR)$(bindir)/$(progname)
|
||||
$(INSTALL_SCRIPT) zcat $(DESTDIR)$(bindir)/zcat
|
||||
$(INSTALL_SCRIPT) zcmp $(DESTDIR)$(bindir)/zcmp
|
||||
|
@ -94,14 +103,15 @@ install : all install-info install-man
|
|||
$(INSTALL_SCRIPT) zegrep $(DESTDIR)$(bindir)/zegrep
|
||||
$(INSTALL_SCRIPT) zfgrep $(DESTDIR)$(bindir)/zfgrep
|
||||
$(INSTALL_SCRIPT) zgrep $(DESTDIR)$(bindir)/zgrep
|
||||
$(INSTALL_SCRIPT) ztest $(DESTDIR)$(bindir)/ztest
|
||||
|
||||
install-info :
|
||||
if test ! -d $(DESTDIR)$(infodir) ; then $(INSTALL_DIR) $(DESTDIR)$(infodir) ; fi
|
||||
if [ ! -d $(DESTDIR)$(infodir) ] ; then $(INSTALL_DIR) $(DESTDIR)$(infodir) ; fi
|
||||
$(INSTALL_DATA) $(VPATH)/doc/$(progname).info $(DESTDIR)$(infodir)/$(progname).info
|
||||
-install-info --info-dir=$(DESTDIR)$(infodir) $(DESTDIR)$(infodir)/$(progname).info
|
||||
|
||||
install-man :
|
||||
if test ! -d $(DESTDIR)$(mandir)/man1 ; then $(INSTALL_DIR) $(DESTDIR)$(mandir)/man1 ; fi
|
||||
if [ ! -d $(DESTDIR)$(mandir)/man1 ] ; then $(INSTALL_DIR) $(DESTDIR)$(mandir)/man1 ; fi
|
||||
$(INSTALL_DATA) $(VPATH)/doc/zcat.1 $(DESTDIR)$(mandir)/man1/zcat.1
|
||||
-rm -f $(DESTDIR)$(mandir)/man1/zcmp.1
|
||||
cd $(DESTDIR)$(mandir)/man1 && ln -s zdiff.1 zcmp.1
|
||||
|
@ -111,6 +121,7 @@ install-man :
|
|||
-rm -f $(DESTDIR)$(mandir)/man1/zfgrep.1
|
||||
cd $(DESTDIR)$(mandir)/man1 && ln -s zgrep.1 zegrep.1
|
||||
cd $(DESTDIR)$(mandir)/man1 && ln -s zgrep.1 zfgrep.1
|
||||
$(INSTALL_DATA) $(VPATH)/doc/ztest.1 $(DESTDIR)$(mandir)/man1/ztest.1
|
||||
|
||||
install-strip : all
|
||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||
|
@ -123,6 +134,7 @@ uninstall : uninstall-info uninstall-man
|
|||
-rm -f $(DESTDIR)$(bindir)/zegrep
|
||||
-rm -f $(DESTDIR)$(bindir)/zfgrep
|
||||
-rm -f $(DESTDIR)$(bindir)/zgrep
|
||||
-rm -f $(DESTDIR)$(bindir)/ztest
|
||||
|
||||
uninstall-info :
|
||||
-install-info --info-dir=$(DESTDIR)$(infodir) --remove $(DESTDIR)$(infodir)/$(progname).info
|
||||
|
@ -135,6 +147,7 @@ uninstall-man :
|
|||
-rm -f $(DESTDIR)$(mandir)/man1/zegrep.1
|
||||
-rm -f $(DESTDIR)$(mandir)/man1/zfgrep.1
|
||||
-rm -f $(DESTDIR)$(mandir)/man1/zgrep.1
|
||||
-rm -f $(DESTDIR)$(mandir)/man1/ztest.1
|
||||
|
||||
dist :
|
||||
ln -sf $(VPATH) $(DISTNAME)
|
||||
|
|
7
NEWS
7
NEWS
|
@ -1,3 +1,6 @@
|
|||
Changes in version 0.6:
|
||||
Changes in version 0.7:
|
||||
|
||||
Format of data read from stdin is now automatically detected.
|
||||
The new utility ztest, able to recursively test all the compressed files
|
||||
in a directory tree, has been added.
|
||||
|
||||
The option "--recursive" has been added to zcat.
|
||||
|
|
6
README
6
README
|
@ -2,10 +2,10 @@ Description
|
|||
|
||||
Zutils is a collection of utilities for dealing with any combination of
|
||||
compressed and non-compressed files transparently. The supported
|
||||
compressors are gzip, bzip2, lzip and xz.
|
||||
compressors are bzip2, gzip, lzip and xz.
|
||||
|
||||
The currently provided utilities are zcat, zcmp, zdiff, zegrep, zfgrep
|
||||
and zgrep.
|
||||
The currently provided utilities are zcat, zcmp, zdiff, zegrep, zfgrep,
|
||||
zgrep and ztest.
|
||||
|
||||
|
||||
Copyright (C) 2009 Antonio Diaz Diaz.
|
||||
|
|
4
configure
vendored
4
configure
vendored
|
@ -5,12 +5,12 @@
|
|||
# This configure script is free software: you have unlimited permission
|
||||
# to copy, distribute and modify it.
|
||||
#
|
||||
# Date of this version: 2009-10-05
|
||||
# Date of this version: 2009-10-21
|
||||
|
||||
args=
|
||||
no_create=
|
||||
progname=zutils
|
||||
progversion=0.6
|
||||
progversion=0.7
|
||||
srctrigger=zdiff.in
|
||||
|
||||
# clear some things potentially inherited from environment.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
|
||||
.TH ZCAT "1" "October 2009" "Zcat 0.6" "User Commands"
|
||||
.TH ZCAT "1" "October 2009" "Zcat 0.7" "User Commands"
|
||||
.SH NAME
|
||||
Zcat \- concatenate compressed files to stdout
|
||||
.SH SYNOPSIS
|
||||
|
@ -16,7 +16,7 @@ corresponding to the supported compressors. If no files are specified,
|
|||
data is read from standard input, decompressed if needed, and sent to
|
||||
stdout. Data read from standard input must be of the same type; all
|
||||
uncompressed or all compressed with the same compressor.
|
||||
The supported compressors are gzip, bzip2, lzip and xz.
|
||||
The supported compressors are bzip2, gzip, lzip and xz.
|
||||
.PP
|
||||
CAT_OPTIONS are passed directly to cat.
|
||||
The exit status from cat is preserved.
|
||||
|
@ -27,6 +27,9 @@ display this help and exit
|
|||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
output version information and exit
|
||||
.TP
|
||||
\fB\-r\fR, \fB\-\-recursive\fR
|
||||
operate recursively on directories
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to zutils\-bug@nongnu.org
|
||||
Zutils home page: http://www.nongnu.org/zutils/zutils.html
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
|
||||
.TH ZDIFF "1" "October 2009" "Zdiff 0.6" "User Commands"
|
||||
.TH ZDIFF "1" "October 2009" "Zdiff 0.7" "User Commands"
|
||||
.SH NAME
|
||||
Zdiff \- compare compressed files
|
||||
.SH SYNOPSIS
|
||||
|
@ -11,7 +11,7 @@ Zdiff \- Diff/cmp wrapper for compressed files.
|
|||
Zdiff is a wrapper script around the diff and cmp commands that allows
|
||||
transparent comparison of any combination of compressed and
|
||||
non\-compressed files. If any given file is compressed, its uncompressed
|
||||
content is used. The supported compressors are gzip, bzip2, lzip and xz.
|
||||
content is used. The supported compressors are bzip2, gzip, lzip and xz.
|
||||
.PP
|
||||
Zcmp is a shortcut for "zdiff \fB\-\-cmp\fR"
|
||||
.PP
|
||||
|
@ -19,7 +19,7 @@ Compares FILE1 to FILE2. If FILE2 is omitted and FILE1 is compressed,
|
|||
compares FILE1 to the file with the corresponding decompressed file
|
||||
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).
|
||||
FILE1.[bz2|gz|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.
|
||||
.SH OPTIONS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
|
||||
.TH ZGREP "1" "October 2009" "Zgrep 0.6" "User Commands"
|
||||
.TH ZGREP "1" "October 2009" "Zgrep 0.7" "User Commands"
|
||||
.SH NAME
|
||||
Zgrep \- search compressed files for a regular expression
|
||||
.SH SYNOPSIS
|
||||
|
@ -16,7 +16,7 @@ names corresponding to the supported compressors. If no files are
|
|||
specified, data is read from standard input, decompressed if needed, and
|
||||
fed to grep. Data read from standard input must be of the same type; all
|
||||
uncompressed or all compressed with the same compressor.
|
||||
The supported compressors are gzip, bzip2, lzip and xz.
|
||||
The supported compressors are bzip2, gzip, lzip and xz.
|
||||
.PP
|
||||
Zegrep is a shortcut for "zgrep \fB\-E\fR"
|
||||
Zfgrep is a shortcut for "zgrep \fB\-F\fR"
|
||||
|
|
40
doc/ztest.1
Normal file
40
doc/ztest.1
Normal file
|
@ -0,0 +1,40 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.36.
|
||||
.TH ZTEST "1" "October 2009" "Ztest 0.7" "User Commands"
|
||||
.SH NAME
|
||||
Ztest \- verify integrity of compressed files
|
||||
.SH SYNOPSIS
|
||||
.B ztest
|
||||
[\fIOPTIONS\fR] [\fIFILES\fR]
|
||||
.SH DESCRIPTION
|
||||
Ztest \- Test integrity of compressed files.
|
||||
.PP
|
||||
Ztest verifies the integrity of the specified compressed files.
|
||||
Non\-compressed files are ignored. If no files are specified, the
|
||||
integrity of compressed data read from standard input is verified. Data
|
||||
read from standard input must be all compressed with the same compressor.
|
||||
The supported compressors are bzip2, gzip, lzip and xz.
|
||||
.PP
|
||||
The exit status is 1 if any compressed file is corrupt, 0 otherwise.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
display this help and exit
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
output version information and exit
|
||||
.TP
|
||||
\fB\-q\fR, \fB\-\-quiet\fR
|
||||
suppress all messages
|
||||
.TP
|
||||
\fB\-r\fR, \fB\-\-recursive\fR
|
||||
operate recursively on directories
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
be verbose (a 2nd \fB\-v\fR gives more)
|
||||
.SH "REPORTING BUGS"
|
||||
Report bugs to zutils\-bug@nongnu.org
|
||||
Zutils home page: http://www.nongnu.org/zutils/zutils.html
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2009 Antonio Diaz Diaz.
|
||||
This script is free software: you have unlimited permission
|
||||
to copy, distribute and modify it.
|
BIN
doc/zutils.info
BIN
doc/zutils.info
Binary file not shown.
|
@ -1,12 +1,12 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header
|
||||
@setfilename zutils.info
|
||||
@settitle Zutils
|
||||
@settitle Zutils Manual
|
||||
@finalout
|
||||
@c %**end of header
|
||||
|
||||
@set UPDATED 5 October 2009
|
||||
@set VERSION 0.6
|
||||
@set UPDATED 21 October 2009
|
||||
@set VERSION 0.7
|
||||
|
||||
@dircategory Data Compression
|
||||
@direntry
|
||||
|
@ -36,6 +36,7 @@ This manual is for Zutils (version @value{VERSION}, @value{UPDATED}).
|
|||
* Zcat:: Concatenating compressed files
|
||||
* Zcmp/Zdiff:: Comparing compressed files
|
||||
* Zgrep:: Searching inside compressed files
|
||||
* Ztest:: Testing integrity of compressed files
|
||||
* Problems:: Reporting bugs
|
||||
* Concept Index:: Index of concepts
|
||||
@end menu
|
||||
|
@ -53,10 +54,10 @@ to copy, distribute and modify it.
|
|||
|
||||
Zutils is a collection of utilities for dealing with any combination of
|
||||
compressed and non-compressed files transparently. The supported
|
||||
compressors are gzip, bzip2, lzip and xz.
|
||||
compressors are bzip2, gzip, lzip and xz.
|
||||
|
||||
The currently provided utilities are zcat, zcmp, zdiff, zegrep, zfgrep
|
||||
and zgrep.
|
||||
The currently provided utilities are zcat, zcmp, zdiff, zegrep, zfgrep,
|
||||
zgrep and ztest.
|
||||
|
||||
|
||||
@node Zcat
|
||||
|
@ -93,6 +94,10 @@ Print an informative help message describing the options and exit.
|
|||
@itemx -V
|
||||
Print the version number of zcat on the standard output and exit.
|
||||
|
||||
@item --recursive
|
||||
@itemx -r
|
||||
Operate recursively on directories.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
|
@ -121,7 +126,7 @@ Compares @var{file1} to @var{file2}. If @var{file2} is omitted and
|
|||
corresponding decompressed file name (removes the extension from
|
||||
@var{file1}). If @var{file2} is omitted and @var{file1} is not
|
||||
compressed, compares @var{file1} to the uncompressed contents of
|
||||
@var{file1}.[gz|bz2|lz|xz] (the first one that is found).
|
||||
@var{file1}.[bz2|gz|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.
|
||||
|
||||
|
@ -192,6 +197,51 @@ Print the version number of zgrep on the standard output and exit.
|
|||
@end table
|
||||
|
||||
|
||||
@node Ztest
|
||||
@chapter Ztest
|
||||
@cindex ztest
|
||||
|
||||
Ztest verifies the integrity of the specified compressed files.
|
||||
Non-compressed files are ignored. If no files are specified, the
|
||||
integrity of compressed data read from standard input is verified. Data
|
||||
read from standard input must be all compressed with the same compressor.
|
||||
|
||||
The format for running ztest is:
|
||||
|
||||
@example
|
||||
ztest [@var{options}] [@var{files}]
|
||||
@end example
|
||||
|
||||
@noindent
|
||||
The exit status is 0 if all files verify OK, 1 otherwise.
|
||||
|
||||
Ztest supports the following options:
|
||||
|
||||
@table @samp
|
||||
@item --help
|
||||
@itemx -h
|
||||
Print an informative help message describing the options and exit.
|
||||
|
||||
@item --version
|
||||
@itemx -V
|
||||
Print the version number of ztest on the standard output and exit.
|
||||
|
||||
@item --quiet
|
||||
@itemx -q
|
||||
Quiet operation. Suppress all messages.
|
||||
|
||||
@item --recursive
|
||||
@itemx -r
|
||||
Operate recursively on directories.
|
||||
|
||||
@item --verbose
|
||||
@itemx -v
|
||||
Verbose mode. Show the verify status for each file processed.
|
||||
Further -v's increase the verbosity level.
|
||||
|
||||
@end table
|
||||
|
||||
|
||||
@node Problems
|
||||
@chapter Reporting Bugs
|
||||
@cindex bugs
|
||||
|
|
4
main.cc
4
main.cc
|
@ -551,8 +551,8 @@ int print_magic_type( const std::string & magic_type )
|
|||
{
|
||||
std::string data;
|
||||
|
||||
if( magic_type == "gzip" ) std::printf( "\x1F\x8B" );
|
||||
else if( magic_type == "bzip2" ) std::printf( "BZh" );
|
||||
if( magic_type == "bzip2" ) std::printf( "BZh" );
|
||||
else if( magic_type == "gzip" ) std::printf( "\x1F\x8B" );
|
||||
else if( magic_type == "lzip" ) std::printf( "LZIP" );
|
||||
else if( magic_type == "xz" ) std::printf( "%c7zXZ", '\xFD' );
|
||||
else if( hex_to_data( magic_type, data ) ) std::printf( data.c_str() );
|
||||
|
|
|
@ -15,10 +15,12 @@ ZDIFF="${objdir}"/zdiff
|
|||
ZGREP="${objdir}"/zgrep
|
||||
ZEGREP="${objdir}"/zegrep
|
||||
ZFGREP="${objdir}"/zfgrep
|
||||
ZTEST="${objdir}"/ztest
|
||||
ZUTILS="${objdir}"/zutils
|
||||
compressors="gzip bzip2 lzip"
|
||||
compressors="bzip2 gzip lzip"
|
||||
extensions="gz bz2 lz"
|
||||
framework_failure() { echo 'failure in testing framework'; exit 1; }
|
||||
compressor_needed() { echo "${compressors} are needed to run tests"; exit 1; }
|
||||
|
||||
if [ ! -x "${ZCAT}" ] ; then
|
||||
echo "${ZCAT}: cannot execute"
|
||||
|
@ -27,15 +29,14 @@ fi
|
|||
|
||||
if [ -d tmp ] ; then rm -rf tmp ; fi
|
||||
mkdir tmp
|
||||
echo -n "testing zutils..."
|
||||
cd "${objdir}"/tmp
|
||||
|
||||
for i in ${compressors}; do
|
||||
cat "${testdir}"/../COPYING > in || framework_failure
|
||||
$i in || framework_failure
|
||||
echo -n .
|
||||
$i in || compressor_needed
|
||||
done
|
||||
|
||||
echo -n "testing zutils..."
|
||||
cat "${testdir}"/../COPYING > in || framework_failure
|
||||
cat in > -in- || framework_failure
|
||||
cat in.lz > -in-.lz || framework_failure
|
||||
|
@ -136,10 +137,15 @@ echo -n .
|
|||
"${ZFGREP}" License in 2>&1 > /dev/null || fail=1
|
||||
echo -n .
|
||||
|
||||
if [ "gzip" != `"${ZUTILS}" -t in.gz` ]; then fail=1 ; fi
|
||||
"${ZTEST}" in in.gz in.bz2 in.lz -- -in- || fail=1
|
||||
echo -n .
|
||||
"${ZTEST}" -r . || fail=1
|
||||
echo -n .
|
||||
|
||||
if [ "bzip2" != `"${ZUTILS}" -t in.bz2` ] ; then fail=1 ; fi
|
||||
echo -n .
|
||||
if [ "gzip" != `"${ZUTILS}" -t in.gz` ] ; then fail=1 ; fi
|
||||
echo -n .
|
||||
if [ "lzip" != `"${ZUTILS}" -t in.lz` ] ; then fail=1 ; fi
|
||||
echo -n .
|
||||
|
||||
|
|
23
zcat.in
23
zcat.in
|
@ -8,6 +8,9 @@
|
|||
LC_ALL=C
|
||||
export LC_ALL
|
||||
args=
|
||||
gz_args=
|
||||
xz_args=
|
||||
recursive=0
|
||||
two_hyphens=0
|
||||
|
||||
# Loop over args until a filename is found
|
||||
|
@ -25,7 +28,7 @@ while [ x"$1" != x ] ; do
|
|||
echo "data is read from standard input, decompressed if needed, and sent to"
|
||||
echo "stdout. 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 "Usage: $0 [OPTIONS] [CAT_OPTIONS] [FILES]"
|
||||
echo
|
||||
|
@ -35,6 +38,7 @@ while [ x"$1" != x ] ; do
|
|||
echo "Options:"
|
||||
echo " -h, --help display this help and exit"
|
||||
echo " -V, --version output version information and exit"
|
||||
echo " -r, --recursive operate recursively on directories"
|
||||
echo
|
||||
echo "Report bugs to zutils-bug@nongnu.org"
|
||||
echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html"
|
||||
|
@ -45,8 +49,12 @@ while [ x"$1" != x ] ; do
|
|||
echo "This script is free software: you have unlimited permission"
|
||||
echo "to copy, distribute and modify it."
|
||||
exit 0 ;;
|
||||
- | -f)
|
||||
- | -c | --st* | -d | --de* | -f | --fo* | -q | --qu* | -L | --lic* )
|
||||
;;
|
||||
-l | --lis*)
|
||||
gz_args="${gz_args} $1"; xz_args="${xz_args} $1" ;;
|
||||
-r | --re*)
|
||||
recursive=1 ;;
|
||||
--)
|
||||
shift ; two_hyphens=1 ; break ;;
|
||||
-?*)
|
||||
|
@ -61,10 +69,10 @@ 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" ;;
|
||||
gzip) prog="gzip -cdfq ${gz_args}" ;;
|
||||
lzip) prog="lzip -cdfq" ;;
|
||||
xz) prog="xz -cdfq" ;;
|
||||
xz) prog="xz -cdfq ${xz_args}" ;;
|
||||
*) prog=cat ;;
|
||||
esac
|
||||
{ "${bindir}"zutils -m ${prog_name} ; cat ; } | ${prog} | cat ${args}
|
||||
|
@ -80,6 +88,9 @@ for i in "$@" ; do
|
|||
elif [ -f "$i.bz2" ] ; then i="$i.bz2"
|
||||
elif [ -f "$i.lz" ] ; then i="$i.lz"
|
||||
elif [ -f "$i.xz" ] ; then i="$i.xz"
|
||||
elif [ ${recursive} = 1 ] && [ -d "$i" ] ; then
|
||||
find "$i" -type f -exec "$0" '{}' ';'
|
||||
continue
|
||||
else
|
||||
echo "$0: File \"$i\" not found or not a regular file" 1>&2
|
||||
if [ ${retval} = 0 ] ; then retval=1 ; fi
|
||||
|
@ -89,10 +100,10 @@ for i in "$@" ; do
|
|||
bindir=`echo "$0" | sed -e 's,[^/]*$,,'`
|
||||
prog_name=`"${bindir}"zutils -t -- "$i"`
|
||||
case "${prog_name}" in
|
||||
gzip) prog="gzip -cdfq" ;;
|
||||
bzip2) prog="bzip2 -cdfq" ;;
|
||||
gzip) prog="gzip -cdfq ${gz_args}" ;;
|
||||
lzip) prog="lzip -cdfq" ;;
|
||||
xz) prog="xz -cdfq" ;;
|
||||
xz) prog="xz -cdfq ${xz_args}" ;;
|
||||
*) prog=cat ;;
|
||||
esac
|
||||
${prog} -- "$i" | cat ${args}
|
||||
|
|
22
zdiff.in
22
zdiff.in
|
@ -23,7 +23,7 @@ while [ x"$1" != x ] ; do
|
|||
echo "Zdiff is a wrapper script around the diff and cmp commands that allows"
|
||||
echo "transparent comparison of any combination of compressed and"
|
||||
echo "non-compressed files. If any given file is compressed, its uncompressed"
|
||||
echo "content is used. The supported compressors are gzip, bzip2, lzip and xz."
|
||||
echo "content is used. The supported compressors are bzip2, gzip, lzip and xz."
|
||||
echo
|
||||
echo "Zcmp is a shortcut for \"zdiff --cmp\""
|
||||
echo
|
||||
|
@ -33,7 +33,7 @@ while [ x"$1" != x ] ; do
|
|||
echo "compares FILE1 to the file with the corresponding decompressed file"
|
||||
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 "FILE1.[bz2|gz|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
|
||||
|
@ -95,18 +95,18 @@ fi
|
|||
|
||||
if [ -z "${file2}" ] ; then
|
||||
case "${file1}" in
|
||||
*.gz) file2=`printf "%s" "${file1}" | sed -e 's,.gz$,,'` ;;
|
||||
*.tgz) file2=`printf "%s" "${file1}" | sed -e 's,tgz$,tar,'` ;;
|
||||
*.bz2) file2=`printf "%s" "${file1}" | sed -e 's,.bz2$,,'` ;;
|
||||
*.tbz) file2=`printf "%s" "${file1}" | sed -e 's,tbz$,tar,'` ;;
|
||||
*.tbz2) file2=`printf "%s" "${file1}" | sed -e 's,tbz2$,tar,'` ;;
|
||||
*.gz) file2=`printf "%s" "${file1}" | sed -e 's,.gz$,,'` ;;
|
||||
*.tgz) file2=`printf "%s" "${file1}" | sed -e 's,tgz$,tar,'` ;;
|
||||
*.lz) file2=`printf "%s" "${file1}" | sed -e 's,.lz$,,'` ;;
|
||||
*.tlz) file2=`printf "%s" "${file1}" | sed -e 's,tlz$,tar,'` ;;
|
||||
*.xz) file2=`printf "%s" "${file1}" | sed -e 's,.xz$,,'` ;;
|
||||
*.txz) file2=`printf "%s" "${file1}" | sed -e 's,txz$,tar,'` ;;
|
||||
*)
|
||||
if [ -f "${file1}.gz" ]; then file2="${file1}.gz"
|
||||
elif [ -f "${file1}.bz2" ]; then file2="${file1}.bz2"
|
||||
if [ -f "${file1}.bz2" ] ; then file2="${file1}.bz2"
|
||||
elif [ -f "${file1}.gz" ] ; then file2="${file1}.gz"
|
||||
elif [ -f "${file1}.lz" ] ; then file2="${file1}.lz"
|
||||
elif [ -f "${file1}.xz" ] ; then file2="${file1}.xz"
|
||||
else
|
||||
|
@ -122,19 +122,13 @@ bindir=`echo "$0" | sed -e 's,[^/]*$,,'`
|
|||
if [ -f "${file1}" ] ; then
|
||||
prog_name=`"${bindir}"zutils -t -- "${file1}"`
|
||||
case "${prog_name}" in
|
||||
gzip) prog1=gzip ;;
|
||||
bzip2) prog1=bzip2 ;;
|
||||
lzip) prog1=lzip ;;
|
||||
xz) prog1=xz ;;
|
||||
bzip2 | gzip | lzip | xz) prog1=${prog_name} ;;
|
||||
esac
|
||||
fi
|
||||
if [ -f "${file2}" ] ; then
|
||||
prog_name=`"${bindir}"zutils -t -- "${file2}"`
|
||||
case "${prog_name}" in
|
||||
gzip) prog2=gzip ;;
|
||||
bzip2) prog2=bzip2 ;;
|
||||
lzip) prog2=lzip ;;
|
||||
xz) prog2=xz ;;
|
||||
bzip2 | gzip | lzip | xz) prog2=${prog_name} ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
|
12
zgrep.in
12
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\""
|
||||
|
@ -87,10 +87,7 @@ 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}
|
||||
|
@ -115,10 +112,7 @@ for i in "$@" ; do
|
|||
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
|
||||
|
|
102
ztest.in
Normal file
102
ztest.in
Normal file
|
@ -0,0 +1,102 @@
|
|||
#! /bin/sh
|
||||
# Ztest - Test integrity of compressed files.
|
||||
# Copyright (C) 2009 Antonio Diaz Diaz.
|
||||
#
|
||||
# This script is free software: you have unlimited permission
|
||||
# to copy, distribute and modify it.
|
||||
|
||||
LC_ALL=C
|
||||
export LC_ALL
|
||||
args=
|
||||
recursive=0
|
||||
two_hyphens=0
|
||||
|
||||
# Loop over args until a filename is found
|
||||
while [ x"$1" != x ] ; do
|
||||
|
||||
case "$1" in
|
||||
--help | --he* | -h)
|
||||
echo "Ztest - Test integrity of compressed files."
|
||||
echo
|
||||
echo "Ztest verifies the integrity of the specified compressed files."
|
||||
echo "Non-compressed files are ignored. If no files are specified, the"
|
||||
echo "integrity of compressed data read from standard input is verified. Data"
|
||||
echo "read from standard input must be all compressed with the same compressor."
|
||||
echo "The supported compressors are bzip2, gzip, lzip and xz."
|
||||
echo
|
||||
echo "Usage: $0 [OPTIONS] [FILES]"
|
||||
echo
|
||||
echo "The exit status is 1 if any compressed file is corrupt, 0 otherwise."
|
||||
echo
|
||||
echo "Options:"
|
||||
echo " -h, --help display this help and exit"
|
||||
echo " -V, --version output version information and exit"
|
||||
echo " -q, --quiet suppress all messages"
|
||||
echo " -r, --recursive operate recursively on directories"
|
||||
echo " -v, --verbose be verbose (a 2nd -v gives more)"
|
||||
echo
|
||||
echo "Report bugs to zutils-bug@nongnu.org"
|
||||
echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html"
|
||||
exit 0 ;;
|
||||
--version | --ve* | -V)
|
||||
echo "Ztest VERSION"
|
||||
echo "Copyright (C) 2009 Antonio Diaz Diaz."
|
||||
echo "This script is free software: you have unlimited permission"
|
||||
echo "to copy, distribute and modify it."
|
||||
exit 0 ;;
|
||||
-r | --re*)
|
||||
recursive=1 ;;
|
||||
-v | -vv | -vvv | --ve* | -q | --qu*)
|
||||
args="${args} $1" ;;
|
||||
--)
|
||||
shift ; two_hyphens=1 ; break ;;
|
||||
- | -?*)
|
||||
;;
|
||||
*)
|
||||
break ;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [ $# = 0 ] ; then
|
||||
bindir=`echo "$0" | sed -e 's,[^/]*$,,'`
|
||||
prog=`"${bindir}"zutils -t`
|
||||
case "${prog}" in
|
||||
bzip2 | gzip | lzip | xz)
|
||||
;;
|
||||
*) echo "$0: Unknown data format read from stdin" 1>&2
|
||||
exit 1 ;;
|
||||
esac
|
||||
{ "${bindir}"zutils -m ${prog} ; cat ; } | ${prog} -t ${args}
|
||||
exit $?
|
||||
fi
|
||||
|
||||
retval=0
|
||||
for i in "$@" ; do
|
||||
if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
|
||||
else
|
||||
if [ ! -f "$i" ] ; then
|
||||
if [ ${recursive} = 1 ] && [ -d "$i" ] ; then
|
||||
bad_files=`find "$i" -type f \( -exec "$0" ${args} '{}' ';' -o -print \)`
|
||||
if [ ${retval} = 0 ] && [ -n "${bad_files}" ] ; then retval=1 ; fi
|
||||
continue
|
||||
else
|
||||
echo "$0: File \"$i\" not found or not a regular file" 1>&2
|
||||
if [ ${retval} = 0 ] ; then retval=1 ; fi
|
||||
continue
|
||||
fi
|
||||
fi
|
||||
bindir=`echo "$0" | sed -e 's,[^/]*$,,'`
|
||||
prog=`"${bindir}"zutils -t -- "$i"`
|
||||
case "${prog}" in
|
||||
bzip2 | gzip | lzip | xz)
|
||||
;;
|
||||
*) continue ;;
|
||||
esac
|
||||
${prog} -t ${args} -- "$i"
|
||||
r=$?
|
||||
if [ $r != 0 ] ; then retval=$r ; fi
|
||||
fi
|
||||
done
|
||||
|
||||
exit ${retval}
|
Loading…
Add table
Reference in a new issue