-
Notifications
You must be signed in to change notification settings - Fork 0
/
unpack.in
33 lines (29 loc) · 847 Bytes
/
unpack.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#! @SHELL@
if test $# -eq 0; then
printf '%s: missing file argument\n' "expr "//$0" : '.*/\(.*\)'" >&2
exit 1
fi
status=0
for f in "$@"; do
test -f "$f" ||
{ printf '%s: can’t unpack file (no such file)\n' "$f" >&2
status=1
continue; }
case $f in -*) f=./$f ;; esac
case "$f" in
*.tar) tar xf "$f" ;;
*.tar.bz2|*.tbz2) bunzip2 "$f" | tar x ;;
*.tar.gz|*.tgz) gunzip "$f" | tar x ;;
*.tar.lzma) unlzma "$f" | tar x ;;
*.tar.xz) unxz "$f" | tar x ;;
*.tar.Z) uncompress "$f" | tar x ;;
*.gz) gunzip "$f" ;;
*.bz2) bunzip2 "$f" ;;
*.rar) unrar x -c- -o+ -idq "$f" ;;
*.zip|*.jar|*.oxt) unzip -q -o "$f" ;;
*.Z) uncompress -f "$f" ;;
*.7z) 7z x "$f" ;;
*) printf '%s: unknown format (unrecognized extension)\n' "$f" >&2; false ;;
esac || status=1
done
exit $status