|
|
@ -12,6 +12,7 @@ local success |
|
|
|
local file_name |
|
|
|
local file_name |
|
|
|
local file_path |
|
|
|
local file_path |
|
|
|
local extract_dir |
|
|
|
local extract_dir |
|
|
|
|
|
|
|
local _gzip_bin _bzip2_bin _xz_bin |
|
|
|
|
|
|
|
|
|
|
|
if (( $# == 0 )); then |
|
|
|
if (( $# == 0 )); then |
|
|
|
cat >&2 <<EOF |
|
|
|
cat >&2 <<EOF |
|
|
@ -30,6 +31,29 @@ if [[ "$1" == "-r" || "$1" == "--remove" ]]; then |
|
|
|
shift |
|
|
|
shift |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# here, we check for dropin/multi-threaded replacements |
|
|
|
|
|
|
|
# this should eventually be moved to modules/archive/init.zsh |
|
|
|
|
|
|
|
# as a global alias |
|
|
|
|
|
|
|
if (( $+commands[pigz] )); then |
|
|
|
|
|
|
|
_gzip_bin='pigz' |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
_gzip_bin='gzip' |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (( $+commands[pixz] )); then |
|
|
|
|
|
|
|
_xz_bin='pixz' |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
_xz_bin='xz' |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (( $+commands[lbzip2] )); then |
|
|
|
|
|
|
|
_bzip2_bin='lbzip2' |
|
|
|
|
|
|
|
elif (( $+commands[pbzip2] )); then |
|
|
|
|
|
|
|
_bzip2_bin='pbzip2' |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
_bzip2_bin='bzip2' |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
while (( $# > 0 )); do |
|
|
|
while (( $# > 0 )); do |
|
|
|
if [[ ! -s "$1" ]]; then |
|
|
|
if [[ ! -s "$1" ]]; then |
|
|
|
print "$0: file not valid: $1" >&2 |
|
|
|
print "$0: file not valid: $1" >&2 |
|
|
@ -42,15 +66,13 @@ while (( $# > 0 )); do |
|
|
|
file_path="${1:A}" |
|
|
|
file_path="${1:A}" |
|
|
|
extract_dir="${file_name:r}" |
|
|
|
extract_dir="${file_name:r}" |
|
|
|
case "$1:l" in |
|
|
|
case "$1:l" in |
|
|
|
(*.tar.gz|*.tgz) tar xvzf "$1" ;; |
|
|
|
(*.tar.gz|*.tgz) tar -xvf "$1" --use-compress-program="${_gzip_bin}" ;; |
|
|
|
(*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; |
|
|
|
(*.tar.bz2|*.tbz|*.tbz2) tar -xvf "$1" --use-compress-program="${_bzip2_bin}" ;; |
|
|
|
(*.tar.xz|*.txz) tar --xz --help &> /dev/null \ |
|
|
|
(*.tar.xz|*.txz) tar -xvf "$1" --use-compress-program="${_xz_bin}" ;; |
|
|
|
&& tar --xz -xvf "$1" \ |
|
|
|
|
|
|
|
|| xzcat "$1" | tar xvf - ;; |
|
|
|
|
|
|
|
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ |
|
|
|
(*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ |
|
|
|
&& tar --lzma -xvf "$1" \ |
|
|
|
&& tar --lzma -xvf "$1" \ |
|
|
|
|| lzcat "$1" | tar xvf - ;; |
|
|
|
|| lzcat "$1" | tar -xvf - ;; |
|
|
|
(*.tar) tar xvf "$1" ;; |
|
|
|
(*.tar) tar -xvf "$1" ;; |
|
|
|
(*.gz) gunzip "$1" ;; |
|
|
|
(*.gz) gunzip "$1" ;; |
|
|
|
(*.bz2) bunzip2 "$1" ;; |
|
|
|
(*.bz2) bunzip2 "$1" ;; |
|
|
|
(*.xz) unxz "$1" ;; |
|
|
|
(*.xz) unxz "$1" ;; |
|
|
|