summaryrefslogtreecommitdiffstats
path: root/zcat.in
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 16:12:15 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 16:12:15 +0000
commit904eea648db33416c7222842a0607f9b7d013656 (patch)
tree01fb0b1be8eff6e37d50938f8200eac45c97f14a /zcat.in
parentAdding debian version 0.5-1. (diff)
downloadzutils-904eea648db33416c7222842a0607f9b7d013656.tar.xz
zutils-904eea648db33416c7222842a0607f9b7d013656.zip
Merging upstream version 0.6.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zcat.in')
-rw-r--r--zcat.in29
1 files changed, 13 insertions, 16 deletions
diff --git a/zcat.in b/zcat.in
index 0721e60..fb7ab73 100644
--- a/zcat.in
+++ b/zcat.in
@@ -8,7 +8,6 @@
LC_ALL=C
export LC_ALL
args=
-default_prog=gzip
two_hyphens=0
# Loop over args until a filename is found
@@ -23,8 +22,9 @@ while [ x"$1" != x ] ; do
echo "If any given file is compressed, its uncompressed content is used. If a"
echo "given file does not exist, zcat tries the compressed file names"
echo "corresponding to the supported compressors. If no files are specified,"
- echo "the standard input is decompressed using the selected compressor and"
- echo "sent to stdout."
+ 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
echo "Usage: $0 [OPTIONS] [CAT_OPTIONS] [FILES]"
@@ -35,10 +35,6 @@ while [ x"$1" != x ] ; do
echo "Options:"
echo " -h, --help display this help and exit"
echo " -V, --version output version information and exit"
- echo " --gzip use gzip as decompressor for stdin (default)"
- echo " --bzip2 use bzip2 as decompressor for stdin"
- echo " --lzip use lzip as decompressor for stdin"
- echo " --xz use xz as decompressor for stdin"
echo
echo "Report bugs to zutils-bug@nongnu.org"
echo "Zutils home page: http://www.nongnu.org/zutils/zutils.html"
@@ -49,14 +45,6 @@ while [ x"$1" != x ] ; do
echo "This script is free software: you have unlimited permission"
echo "to copy, distribute and modify it."
exit 0 ;;
- --gz*)
- default_prog=gzip ;;
- --bz*)
- default_prog=bzip2 ;;
- --lz*)
- default_prog=lzip ;;
- --xz*)
- default_prog=xz ;;
- | -f)
;;
--)
@@ -70,7 +58,16 @@ while [ x"$1" != x ] ; do
done
if [ $# = 0 ]; then
- ${default_prog} -cdfq | cat ${args}
+ 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" ;;
+ *) prog=cat ;;
+ esac
+ { "${bindir}"zutils -m ${prog_name} ; cat ; } | ${prog} | cat ${args}
exit $?
fi