summaryrefslogtreecommitdiff
path: root/etc/functions/extr
blob: 444b237eed1ad1ec4c7b33cb3c0c8d73c36e2268 (plain)
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
# builtin function for archives, see $ZDIR/alias_suffix
## vim:ft=zsh

function confirm_shar {
	echo -ne "${warn}shar archives are shell scripts and can easily contain malicious code.${reset} Proceed? [y/N] "
	read -q
}

if [[ -f $1 ]] {
	case $1 in
		*.tar.bz2) tar xvjf $1 ;;
		*.tar.gz) tar xvzf $1 ;;
		*.ace) unace e $1 ;;
		*.rar) unrar x $1 ;;
		*.deb) ar -x $1 ;;
		*.bz2) bzip2 -d $1 ;;
		*.lzh) lha x $1 ;;
		*.gz) gunzip -d $1 ;;
		*.tar) tar xvf $1 ;;
		*.tgz) xvzf $1 ;;
		*.tbz2) tar xvjf $1 ;;
		*.zip) unzip $1 ;;
		*.Z) uncompress $1 ;;
		*.shar) confirm_shar && sh $1 ;;
		*.cpio) cpio --no-absolute-filenames -idv < $1 ;;
		*.lzma) unlzma $1 ;;
		*) echo "Unknown archive type: $1"; return 2 ;;
	esac
} else {
	echo "Nu soch file: $1"
	exit 1
}