summaryrefslogtreecommitdiff
path: root/scripts/extract.sh
blob: 4a1ad04452af9a02baba993279a0d32e4a9dc7aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
file=$1
shift

case $file in
*.tar.gz|*.tgz) tool=gzip  ;;
*.tar.bz2)      tool=bzip2 ;;
*.tar.xz)       tool=xz    ;;
*) exit 0
esac

if command -v bsdtar >/dev/null; then
	exec bsdtar -xf "$file" "$@"
elif command -v pax >/dev/null; then
	"$tool" -d -c "$file" | pax -r "$@"
else
	printf '%s: bsdtar or pax is required' "$0" >&2
	exit 1
fi