summaryrefslogtreecommitdiffstats
path: root/zcat.in
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 16:11:09 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 16:11:09 +0000
commitececf5b1557dc45df52d1d1c5e7f8bc18c940301 (patch)
treeefe5eb51699a6d5ba86cb91c6259d23b7eb65320 /zcat.in
parentAdding debian version 0.3-1. (diff)
downloadzutils-ececf5b1557dc45df52d1d1c5e7f8bc18c940301.tar.xz
zutils-ececf5b1557dc45df52d1d1c5e7f8bc18c940301.zip
Merging upstream version 0.4.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zcat.in')
-rw-r--r--zcat.in40
1 files changed, 19 insertions, 21 deletions
diff --git a/zcat.in b/zcat.in
index bf3f07a..9b7edf5 100644
--- a/zcat.in
+++ b/zcat.in
@@ -59,28 +59,26 @@ retval=0
for i in "$@" ; do
if [ "$i" = "--" ] && [ ${two_hyphens} = 0 ] ; then two_hyphens=1
else
- if [ -f "$i" ]; then
- case "$i" in
- *.gz | *.tgz)
- prog="gzip -cdfq" ;;
- *.bz2 | *.tbz | *.tbz2)
- 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
+ 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
+ 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" ;;
+ *) prog=cat ;;
+ esac
${prog} -- "$i" | cat ${args}
r=$?
if [ $r != 0 ]; then retval=$r ; fi