From 4de0377106a6558c4b9174c91d8fcde102f92d5a Mon Sep 17 00:00:00 2001 From: Poscat Date: Sat, 7 Nov 2020 18:35:08 +0800 Subject: [PATCH] Add support for zstd compressed tarballs to module 'archive' --- modules/archive/functions/_lsarchive | 2 +- modules/archive/functions/_unarchive | 2 +- modules/archive/functions/archive | 7 +++++-- modules/archive/functions/lsarchive | 1 + modules/archive/functions/unarchive | 5 ++++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/modules/archive/functions/_lsarchive b/modules/archive/functions/_lsarchive index f2cee88..bcbfbd6 100644 --- a/modules/archive/functions/_lsarchive +++ b/modules/archive/functions/_lsarchive @@ -10,4 +10,4 @@ _arguments \ '(-v --verbose)'{-v,--remove}'[verbose archive listing]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|jar|rar|7z)(-.)'" && return 0 + "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|zst|jar|rar|7z)(-.)'" && return 0 diff --git a/modules/archive/functions/_unarchive b/modules/archive/functions/_unarchive index 90e32f1..6a940b1 100644 --- a/modules/archive/functions/_unarchive +++ b/modules/archive/functions/_unarchive @@ -10,4 +10,4 @@ _arguments \ '(-r --remove)'{-r,--remove}'[remove archive]' \ - "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|jar|rar|7z|deb)(-.)'" && return 0 + "*::archive file:_files -g '(#i)*.(tar|tgz|tbz|tbz2|txz|tlz|gz|bz2|xz|lzma|Z|zip|zst|jar|rar|7z|deb)(-.)'" && return 0 diff --git a/modules/archive/functions/archive b/modules/archive/functions/archive index 10bbad3..75084da 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 _xz_bin +local archive_name path_to_archive _gzip_bin _bzip2_bin _xz_bin _zstd_bin if (( $# < 2 )); then cat >&2 < 0 )); do (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ && tar --lzma -t${verbose:+v}f "$1" \ || lzcat "$1" | tar x${verbose:+v}f - ;; + (*.tar.zst|*.tzst) tar -I zstd -t${verbose:+v}f "$1" ;; (*.tar) tar t${verbose:+v}f "$1" ;; (*.zip|*.jar) unzip -l${verbose:+v} "$1" ;; (*.rar) ( (( $+commands[unrar] )) \ diff --git a/modules/archive/functions/unarchive b/modules/archive/functions/unarchive index 9e38a80..66c7e35 100644 --- a/modules/archive/functions/unarchive +++ b/modules/archive/functions/unarchive @@ -12,7 +12,7 @@ local success local file_name local file_path local extract_dir -local _gzip_bin _bzip2_bin _xz_bin +local _gzip_bin _bzip2_bin _xz_bin _zstd_bin if (( $# == 0 )); then cat >&2 < 0 )); do if [[ ! -s "$1" ]]; then print "$0: file not valid: $1" >&2 @@ -72,6 +74,7 @@ while (( $# > 0 )); do (*.tar.zma|*.tlz) tar --lzma --help &> /dev/null \ && tar --lzma -xvf "$1" \ || lzcat "$1" | tar -xvf - ;; + (*.tar.zst|*.tzst) tar -xvf "$1" --use-compress-program="${_zstd_bin}" ;; (*.tar) tar -xvf "$1" ;; (*.gz) gunzip "$1" ;; (*.bz2) bunzip2 "$1" ;;