From 5d7c990eec21e83c0735f6b8e7d1d669102cbb4f Mon Sep 17 00:00:00 2001 From: Maxim Baz Date: Sun, 17 Feb 2019 00:31:54 +0100 Subject: [PATCH] archive: enhance parallel operations --- modules/archive/functions/archive | 14 ++++++++--- modules/archive/functions/unarchive | 36 +++++++++++++++++++++++------ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/modules/archive/functions/archive b/modules/archive/functions/archive index fab409e..10bbad3 100644 --- a/modules/archive/functions/archive +++ b/modules/archive/functions/archive @@ -8,7 +8,7 @@ # function archive { -local archive_name path_to_archive _gzip_bin _bzip2_bin +local archive_name path_to_archive _gzip_bin _bzip2_bin _xz_bin if (( $# < 2 )); then cat >&2 <&2 < 0 )); do if [[ ! -s "$1" ]]; then print "$0: file not valid: $1" >&2 @@ -42,15 +66,13 @@ while (( $# > 0 )); do file_path="${1:A}" extract_dir="${file_name:r}" case "$1:l" in - (*.tar.gz|*.tgz) tar xvzf "$1" ;; - (*.tar.bz2|*.tbz|*.tbz2) tar xvjf "$1" ;; - (*.tar.xz|*.txz) tar --xz --help &> /dev/null \ - && tar --xz -xvf "$1" \ - || xzcat "$1" | tar xvf - ;; + (*.tar.gz|*.tgz) tar -xvf "$1" --use-compress-program="${_gzip_bin}" ;; + (*.tar.bz2|*.tbz|*.tbz2) tar -xvf "$1" --use-compress-program="${_bzip2_bin}" ;; + (*.tar.xz|*.txz) tar -xvf "$1" --use-compress-program="${_xz_bin}" ;; (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ && tar --lzma -xvf "$1" \ - || lzcat "$1" | tar xvf - ;; - (*.tar) tar xvf "$1" ;; + || lzcat "$1" | tar -xvf - ;; + (*.tar) tar -xvf "$1" ;; (*.gz) gunzip "$1" ;; (*.bz2) bunzip2 "$1" ;; (*.xz) unxz "$1" ;;