diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 15:57:18 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 15:57:18 +0000 |
commit | e0310a3e54eb3ed0938c63f6df4528520b6c0e51 (patch) | |
tree | 8079176d348230619f2d1ae9dedc1f4ec27f9e61 /zcat.in | |
parent | Initial commit. (diff) | |
download | zutils-e0310a3e54eb3ed0938c63f6df4528520b6c0e51.tar.xz zutils-e0310a3e54eb3ed0938c63f6df4528520b6c0e51.zip |
Adding upstream version 0.2.upstream/0.2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'zcat.in')
-rw-r--r-- | zcat.in | 107 |
1 files changed, 107 insertions, 0 deletions
@@ -0,0 +1,107 @@ +#! /bin/sh +# Zcat - Cat wrapper for 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 +invocation_name=$0 +args= +default_prog=lzip + +# Loop over args until pattern is found +while [ x"$1" != x ] ; do + + case "$1" in + --help | --he* | -h) + echo "Zcat - Cat wrapper for compressed files." + echo + echo "Zcat is a wrapper script around the cat command that allows" + echo "transparent concatenation of any combination of compressed and" + 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 "compressed file name corresponding to the default compressor selected." + echo "The supported compressors are gzip, bzip2, lzip and xz." + echo + echo "Usage: ${invocation_name} [OPTIONS] [CAT_OPTIONS] [FILES]" + echo + echo "CAT_OPTIONS are passed directly to cat." + echo "The exit status from cat is preserved." + echo + echo "Options:" + echo " -h, --help display this help 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 "Report bugs to lzip-bug@nongnu.org" + echo "Lzip home page: http://www.nongnu.org/lzip/lzip.html" + exit 0 ;; + --version | --ve* | -V) + echo "Zcat 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 ;; + --gz*) + default_prog=gzip ;; + --bz*) + default_prog=bzip2 ;; + --lz*) + default_prog=lzip ;; + --xz*) + default_prog=xz ;; + -) + ;; + --) + shift; break ;; + -?*) + args="${args} $1" ;; + *) + break ;; + esac + shift +done + +if test $# -eq 0; then + ${default_prog} -cd | cat ${args} + exit $? +fi + +retval=0 +for i in "$@" ; do + prog="${default_prog} -cdfq" + 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 + ${prog} -- "$i" | cat ${args} + r=$? + test "$r" -ne 0 && retval="$r" +done + +exit ${retval} |