diff --git a/archwrap_alias b/archwrap_alias index 7b3a400..cfd2fbf 100644 --- a/archwrap_alias +++ b/archwrap_alias @@ -12,6 +12,8 @@ alias brod='tgzd -BX' alias bzipd='tgzd -bX' alias lzmad='tgzd -lX' alias txzd='tgzd -L' +alias tzsd='tgzd -z' +alias tzstd='tgzd -zX' alias xzd='tgzd -LX' alias 7zd='tgzd -7X' alias lrzd='tgzd -rX' diff --git a/bin/tgzd b/bin/tgzd index 74e5977..45b65fa 100755 --- a/bin/tgzd +++ b/bin/tgzd @@ -20,6 +20,7 @@ Create archive ./zipdir.tgz with contents of zipdir -L use xz (archivename is ./zipdir.txz or ./zipdir.tar.xz) -7 use 7z (archivename is ./zipdir.t7z or ./zipdir.tar.7z) -r use lrzip (archivename is ./zipdir.tlr or ./zipdir.tar.lrz) +-z use zstd (archivename is ./zipdir.tzs or ./zipdir.tar.zst) -t use Tar only (archivename is ./zipdir.tar) -X use long names (.tar.gz instead of .tgz etc) -x use short names (.tgz instead of .tar.gz etc) @@ -67,6 +68,11 @@ case ${0##*/} in *xz*) comp=x xnames=:;; +*tzst*) + comp=z + xnames=:;; +*tzs*) + comp=z;; *bzip*|*.*bz*) comp=b xnames=:;; @@ -95,7 +101,7 @@ case ${0##*/} in comp=;; esac OPTIND=1 -while getopts 'qQAF@:R:SETcCfdDnBbg7lLzmrtpPsXxhH' opt +while getopts 'qQAF@:R:SETcCfdDnBzbg7lLzmrtpPsXxhH' opt do case $opt in q) quiet=:;; Q) quick=:;; @@ -117,6 +123,7 @@ do case $opt in P) calc_version_only=:;; s) sparse=;; B) comp=B;; + B) comp=z;; b) comp=b;; g) comp=g;; [lzm]) comp=l;; @@ -135,7 +142,7 @@ do case $opt in done shift $(( $OPTIND - 1 )) -unset tarprg xzbest brotlibest bzipbest gzipbest sevenzbest lzmabest lrzip +unset tarprg xzbest brotlibest bzipbest gzipbest sevenzbest lzmabest lrzip zstdbest if $calc_version_only then CalcGnuTarVersion && printf '%s' "$GNUTARVERSION" @@ -176,7 +183,8 @@ then Push taropts '-H=exustar' b) Push taropts '-bz' STAR_COMPRESS_FLAG='-9' export STAR_COMPRESS_FLAG;; - [xlr7]) tarcomp=false;; + [xlrz7]) + tarcomp=false;; esac else ! $xattr || ! $tar_knows_xattr || Push taropts '--xattrs' ! $tar_knows_numeric_owner || ! $ownernum || Push taropts '--numeric-owner' @@ -189,6 +197,8 @@ else ! $xattr || ! $tar_knows_xattr || Push taropts '--xattrs' Push taropts '--use-compress-program' "$brotlibest";; b) OptExternal bzipbest Push taropts '--use-compress-program' "$bzipbest";; + z) OptExternal zstdbest + Push taropts '--use-compress-program' "$zstdbest";; g) CalcGzipbest $quick if [ "$gziptext" = gzip ] then Push taropts '--use-compress-program' "$gzipbest" @@ -207,6 +217,7 @@ then case $comp in g) ext='tar.gz';; B) ext='tar.bro';; b) ext='tar.bz2';; + z) ext='tar.zst';; 7) ext='tar.7z';; l) ext='tar.lzma';; x) ext='tar.xz';; @@ -217,6 +228,7 @@ else case $comp in g) ext='tgz';; B) ext='tbr';; b) ext='tbz';; + z) ext='tzs';; 7) ext='t7z';; l) ext='tlz';; x) ext='txz';; @@ -278,14 +290,14 @@ MainLoop() { } StripDirname() { - for strip in taz tgz tbz dir tlz tlrz tlr + for strip in taz tgz tbz dir tlz tlrz tlr tzst tzs tbr tbro do case $dirname in *."$strip") dirname=${dirname%.*} return;; esac done - for strip in z gz bz bz2 7z t7z lz lzm lzma lrz + for strip in z gz bz bz2 7z t7z lz lzm lzma lrz zst bro do case $dirname in *.tar."$strip") dirname=${dirname%.*.*} @@ -320,6 +332,8 @@ DoDir() { "$brotlibest" --input "$archive" --output "$name.$ext";; b) OptExternal bzipbest "$bzipbest" -k -c -- "$archive" >"$name.$ext";; + z) OptExternal zstdbest + "$zstdbest" -o "$name.$ext" -- "$archive";; 7) OptExternal sevenzbest 7zbest "$sevenzbest" <"$archive" >"$name.$ext";; l) OptExternal lzmabest diff --git a/bin/tzsd b/bin/tzsd new file mode 120000 index 0000000..d539287 --- /dev/null +++ b/bin/tzsd @@ -0,0 +1 @@ +tgzd \ No newline at end of file diff --git a/bin/tzstd b/bin/tzstd new file mode 120000 index 0000000..d539287 --- /dev/null +++ b/bin/tzstd @@ -0,0 +1 @@ +tgzd \ No newline at end of file diff --git a/bin/u b/bin/u index dbdd201..4690f47 100755 --- a/bin/u +++ b/bin/u @@ -149,10 +149,12 @@ Getf() { test -f "$f" && return for i in '' .tar .TAR do for j in \ - z bro brotli tbr bz2 bz tbz2 tbz gz tgz taz dir \ + z bro brotli tbr zst zstd tzs tzst tzstd \ + bz2 bz tbz2 tbz gz tgz taz dir \ 7z t7z lz lzm lzma xz tlz txz lrz tlr tlrz lha lzh \ arj arz zip jar xpi crate cra apk okular rar \ - Z BRO BROTLI TBZ BZ2 BZ TBZ2 TBZ GZ TGZ TAZ DIR \ + Z BRO BROTLI TBR ZST ZSTD TZS TZST TZSTD \ + BZ2 BZ TBZ2 TBZ GZ TGZ TAZ DIR \ 7Z T7Z LZ LZM LZMA XZ TLZ TXZ LRZ TLR TLRZ LHA LZH \ ARJ ARZ ZIP JAR XPI CRATE CRA APK OKULAR RAR do f=$1$i.$j @@ -219,6 +221,9 @@ DoCases() { *.tbr|*.TBR) typ='tar.bro' full=:;; + *.tzs|*.tzst|*.tzstd|*.TZS|*.TZST|*.TZSTD) + typ='tar.zst' + full=:;; *.tbz|*.tbz2|*.TBZ|*.TBZ2) typ='tar.bz2' full=:;; @@ -238,6 +243,8 @@ DoCases() { typ='gz';; *.bro|*.brotli|*.BRO|*.BROTLI) typ='bro';; + *.zst|*.zstd|*.ZST|*.ZSTD) + typ='zst';; *.bz|*.bz2|*.BZ|*.BZ2) typ='bz2';; *.lm|*.lzm|*.lzma|*.LM|*.LZM|*.LZMA) @@ -283,7 +290,7 @@ DoCases() { return 0 } -unset bzip bro gzip lzma xz lrzip za unzip unarj lha unrar +unset bzip bro zstd gzip lzma xz lrzip za unzip unarj lha unrar DoIt() { case $typ in tar) @@ -334,6 +341,24 @@ tar.bro) fi || MyErr;; t*) MyErrNot;; esac;; +tar.zst) + OptExternal zstd + case $mode in + u*) IntoDir || return + eval "set -- a $taropts" + shift + if $tar_knows_use_compress_program + then "$tarprg" -x $verboseopt $taruse "$zstd" ${1+"$@"} -f "$f" + else "$zstd" -d --stdout -- "$f" | \ + "$tarprg" -x $verboseopt ${1+"$@"} -f - + fi || MyErr;; + s*) if $tar_knows_use_compress_program + then "$tarprg" -t $verbose $taruse "$zstd" -f "$f" + else "$zstd" -d --stdout -- "$f" | \ + "$tarprg" -t $verbose -f - + fi || MyErr;; + t*) "$zstd" -t -v -- "$f";; + esac;; tar.bz2) OptExternal bzip bzip2 case $mode in @@ -445,20 +470,24 @@ bro) OptExternal bro case $mode in u*) IntoDir || return - if $mdir - then x=$name.bro - "$bro" --decompress --input "$x" --output "$pwdname" - else "$bro" --decompress --input "$f" --output "$pwdname" - fi || MyErr;; + "$bro" --decompress --input "$f" --output "$pwdname" || MyErr;; s*) MyErrNot;; t*) MyErrNot;; esac;; +zst) + OptExternal zstd + case $mode in + u*) IntoDir || return + "$zstd" --d -o "$pwdname" -- "$f" || MyErr;; + s*) "$zstd" -l -v -- "$f";; + t*) "$zstd" -t -v -- "$f";; + esac;; bz2) OptExternal bzip bzip2 case $mode in u*) IntoDir || return if $mdir - then x=$name.gz + then x=$name.bz2 ln -s -- "$f" "$x" || cp -a -- "$f" "$x" \ && "$bzip" -d -- "$x" else "$bzip" -d -k -c -- "$f" >"$pwdname" diff --git a/bin/zstdbest b/bin/zstdbest new file mode 100755 index 0000000..dbe1c0d --- /dev/null +++ b/bin/zstdbest @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +# This script is part of Martin V\"ath's archwrap project. +set -u +exec zstd --ultra -22 ${1+"$@"} diff --git a/zsh/_2pd b/zsh/_2pd index 8aff8cb..9594ea2 100644 --- a/zsh/_2pd +++ b/zsh/_2pd @@ -14,4 +14,4 @@ _arguments -S -A '-*' : \ '-r[rename directories rcs into RCS (requires mmv)]' \ '-q[quiet]' \ '-v[verbose]' \ -'*:archives:_files -g "*.(tar|TAR|z|bro|brotli|tbr|bz2|bz|tbz2|tbz|gz|tgz|taz|dir|7z|t7z|lz|lzm|lzma|xz|tlz|txz|lrz|tlr|tlrz|lha|lzh|arj|arz|zip|jar|xpi|crate|cra|apk|okular|rar|Z|BRO|BROTLI|TBR|BZ2|BZ|TBZ2|TBZ|GZ|TGZ|TAZ|DIR|7Z|T7Z|LZ|LZM|LZMA|XZ|TLZ|TXZ|LRZ|TLR|TLRZ|LHA|LZH|ARJ|ARZ|ZIP|JAR|XPI|CRATE|CRA|APK|OKULAR|RAR)(-.)"' +'*:archives:_files -g "*.(tar|TAR|z|bro|brotli|tbr|zst|zstd|tzst|tzstd|tzs|bz2|bz|tbz2|tbz|gz|tgz|taz|dir|7z|t7z|lz|lzm|lzma|xz|tlz|txz|lrz|tlr|tlrz|lha|lzh|arj|arz|zip|jar|xpi|crate|cra|apk|okular|rar|Z|BRO|BROTLI|TBR|ZST|ZSTD|TZST|TZSTD|TZS|BZ2|BZ|TBZ2|TBZ|GZ|TGZ|TAZ|DIR|7Z|T7Z|LZ|LZM|LZMA|XZ|TLZ|TXZ|LRZ|TLR|TLRZ|LHA|LZH|ARJ|ARZ|ZIP|JAR|XPI|CRATE|CRA|APK|OKULAR|RAR)(-.)"' diff --git a/zsh/_tgzd b/zsh/_tgzd index e482e2b..3603e06 100644 --- a/zsh/_tgzd +++ b/zsh/_tgzd @@ -1,10 +1,11 @@ -#compdef 7zd brod bzipd gzipd lrzd lzmad t7zd tard tbrd tbzd tgzd tlrd tlzd txzd xzd +#compdef 7zd brod bzipd tzsd tzstd gzipd lrzd lzmad t7zd tard tbrd tbzd tgzd tlrd tlzd txzd xzd _arguments -s -S -A '-*' : \ '(* -)'{'-h','-H'}'[help]' \ '-R+[store output in PATH; use e.g. -R - for piping to stdout]:output-path:_files -/' \ '-g[use gzip (appendix .tgz or .tar.gz)]' \ '-B[use brotli (appendix .tbr or .tar.bro)]' \ '-b[use bzip2 (appendix .tbz or .tar.bz2)]' \ +'-z[use zstd (appendix .tzs or .tar.zst)]' \ '-l[use lzma (appendix .tlz or .tar.lzma)]' \ '-L[use xz (appendix .txz or .tar.xz)]' \ '-7[use 7z (appendix .t7z or .tar.7z)]' \ diff --git a/zsh/_u b/zsh/_u index fa04cd5..c57ef78 100644 --- a/zsh/_u +++ b/zsh/_u @@ -22,4 +22,4 @@ _arguments -s -S -A '-*' : \ '-p[ignore GNUTARVERSION]' \ '-P[print output for GNUTARVERSION]' \ '-q[quiet]' \ -'*:archives:_files -g "*.(tar|TAR|z|bro|brotli|tbr|bz2|bz|tbz2|tbz|gz|tgz|taz|dir|7z|t7z|lz|lzm|lzma|xz|tlz|txz|lrz|tlr|tlrz|lha|lzh|arj|arz|zip|jar|xpi|crate|cra|apk|okular|rar|Z|BRO|BROTLI|TBR|BZ2|BZ|TBZ2|TBZ|GZ|TGZ|TAZ|DIR|7Z|T7Z|LZ|LZM|LZMA|XZ|TLZ|TXZ|LRZ|TLR|TLRZ|LHA|LZH|ARJ|ARZ|ZIP|JAR|XPI|CRATE|CRA|APK|OKULAR|RAR)(-.)"' +'*:archives:_files -g "*.(tar|TAR|z|bro|brotli|tbr|zst|zstd|tzst|tzstd|tzs|bz2|bz|tbz2|tbz|gz|tgz|taz|dir|7z|t7z|lz|lzm|lzma|xz|tlz|txz|lrz|tlr|tlrz|lha|lzh|arj|arz|zip|jar|xpi|crate|cra|apk|okular|rar|Z|BRO|BROTLI|TBR|ZST|ZSTD|TZST|TZSTD|TZS|BZ2|BZ|TBZ2|TBZ|GZ|TGZ|TAZ|DIR|7Z|T7Z|LZ|LZM|LZMA|XZ|TLZ|TXZ|LRZ|TLR|TLRZ|LHA|LZH|ARJ|ARZ|ZIP|JAR|XPI|CRATE|CRA|APK|OKULAR|RAR)(-.)"'