2 # Copyright 1994,2002 David C. Niemi.
3 # Copyright 1996,1997,2001-2003,2010 Alain Knaff.
4 # This file is part of mtools.
6 # Mtools is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # Mtools is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Mtools. If not, see <http://www.gnu.org/licenses/>.
21 # If called "uz", gunzips and extracts a gzip'd tar'd archive.
22 # If called "lz", gunzips and shows a listing of a gzip'd tar'd archive.
24 # Requires: gzip and tar in the user's path. Should work with most tars.
25 # "-" is now used for backwards compatibility with antique tars, e.g. SCO.
27 # 1994/02/19 DCN Created (as a trivial, but useful script)
28 # 1994/12/01 DCN Combined uz and lz, added suffix handling
29 # 2002/09/11 DCN Added bzip2 support
30 # 2010/10/16 AKN Added lzip support
32 # Copyright (C) 1994, 2002 David C. Niemi (niemi at tuxers dot net)
33 # The author requires that any copies or derived works include this
34 # copyright notice; no other restrictions are placed on its use.
40 ## Default unzipping command
47 action="Extracting from "
52 action="Reading directory of "
55 echo "$0: expect to be named either \"uz\" or \"lz\"." >&2
61 echo "$action standard input." >&2
62 $uzcmd - | tar "$tarparam" -
66 while [ $# -ge 1 ]; do
70 for suffix in "" .gz .tgz .tar.gz .z .tar.z .taz .tpz .Z .tar.Z .tar.bz2 tar.lz .zip .jar .war .ear .aar .tar.xz; do
71 if [ -r "${1}$suffix" ]; then
82 *.zip | *.jar | *.war | *.ear | *.aar)
92 if [ -z "$found" ]; then
93 echo "$0: could not read \"$1\"." >&2
95 echo "$action \"$found\"." >&2
96 if [ $unzip = 1 ]; then
97 unzip $zipparam -- "$found"
99 $uzcmd -- "$found" | tar "$tarparam" -