1
0
Fork 0

Adding upstream version 0.7.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-24 04:58:36 +01:00
parent c2bdc739f1
commit 0504e18b91
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
17 changed files with 318 additions and 96 deletions

39
zcat.in
View file

@ -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 ;;
-?*)
@ -57,14 +65,14 @@ while [ x"$1" != x ] ; do
shift
done
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" ;;
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}
@ -75,29 +83,32 @@ 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"
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
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" ;;
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}
r=$?
if [ $r != 0 ]; then retval=$r ; fi
if [ $r != 0 ] ; then retval=$r ; fi
fi
done