#!/bin/sh

# extract archives
# depends: unzip unace unrar 7z

if test -z "$1"; then
    echo "usage: $(basename $0) ARCHIVE ..."
    exit 1
fi

while test -n "$1"; do
    case "$1" in
    *.tar.gz | *.tgz) tar xzf "$1";;
    *.tar.bz2 | *.tbz) tar xjf "$1";;
    *.tar.xz) tar xf "$1";;
    *.zip) unzip "$1";;
    *.jar) unzip "$1";;
    *.war) unzip "$1";;
    *.ace) unace x "$1";;
    *.rar) unrar x "$1";;
    *.7z) 7z x "$1";;
    *.tar) tar xf "$1";;
    *.gz) gunzip "$1";;
    *.bz2) bunzip2 "$1";;
    *) echo "file format not supported: $1";;
    esac

    shift
done
