32 lines
816 B
Plaintext
32 lines
816 B
Plaintext
|
#!/bin/sh
|
||
|
# This script emulates and extends the lz and uz commands of the mtools.
|
||
|
# It handles: .tar, .tar.gz, .tar.bz2, .tar.xz and .tar.lzma, through the
|
||
|
# standards options of GNU tar.
|
||
|
# If the script name is "lz", the archive content is displayed. If the name
|
||
|
# is "uz", it is extracted.
|
||
|
|
||
|
PROGRAM=`basename $0`
|
||
|
|
||
|
if [ "$PROGRAM" = "lz" ] ; then
|
||
|
ACTION="t"
|
||
|
elif [ "$PROGRAM" = "uz" ] ; then
|
||
|
ACTION="x"
|
||
|
else
|
||
|
echo '$0 = "'"$0"' (not "lz" nor "uz")!'
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
if [ `basename "$1" .tar` != "$1" ] ; then
|
||
|
FORMAT=""
|
||
|
elif [ `basename "$1" .tar.gz` != "$1" ] ; then
|
||
|
FORMAT="--gzip"
|
||
|
elif [ `basename "$1" .tar.bz2` != "$1" ] ; then
|
||
|
FORMAT="--bzip"
|
||
|
elif [ `basename "$1" .tar.xz` != "$1" ] ; then
|
||
|
FORMAT="--xz"
|
||
|
elif [ `basename "$1" .tar.lzma` != "$1" ] ; then
|
||
|
FORMAT="--lzma"
|
||
|
fi
|
||
|
|
||
|
tar "$FORMAT" -"$ACTION"f "$@"
|