Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Teach 'tar' to support more file types
- X-seq: zsh-workers 42585
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Teach 'tar' to support more file types
- Date: Thu, 5 Apr 2018 12:55:21 +0900
- Cc: Eitan Adler <lists@xxxxxxxxxxxxxx>
- In-reply-to: <CAF6rxg=4Uj3_KdWLwy2vWNvEk6vBr+3YtGrAjvAwQOCUN_H_=Q@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAF6rxg=4Uj3_KdWLwy2vWNvEk6vBr+3YtGrAjvAwQOCUN_H_=Q@mail.gmail.com>
> 2018/04/02 7:10, Eitan Adler <lists@xxxxxxxxxxxxxx> wrote:
>
> In libarchive based (BSD) tar implementations, all file types can be
> uncompressed, even without a filetype letter. In GNU tar's case
> "recent" versions (for over 10 years) can do the same.
> As such, remove the check for tar type and just assume it works.
We can't assume it works since there are many systems where tar requires
explicit compression flags. Even on some BSDs (OpenBSD and NetBSD) tar
is not based on libarchive.
If the tar command is based on libarchive, we can detect it by using
'tar --version'.
diff --git a/Completion/Unix/Command/_tar b/Completion/Unix/Command/_tar
index cff50562e..3e44b98f7 100644
--- a/Completion/Unix/Command/_tar
+++ b/Completion/Unix/Command/_tar
@@ -21,7 +21,7 @@ local _tar_cmd tf tmp tmpb del index
# from some of the possible long options, and from the second word if
# that does not start with a hyphen.
-if _pick_variant gnu=GNU unix --version; then
+if _pick_variant gnu=GNU libarchive=libarchive unix --version; then
case "$($service --version)" in
("tar (GNU tar) "(#b)([0-9.-]##)*)
autoload -z is-at-least
diff --git a/Completion/Unix/Type/_tar_archive b/Completion/Unix/Type/_tar_archive
index 28df77638..e8ddb1e59 100644
--- a/Completion/Unix/Type/_tar_archive
+++ b/Completion/Unix/Type/_tar_archive
@@ -20,7 +20,7 @@ if [[ "$1" = *[urtx]* ]]; then
_files "$expl[@]" -g '*.(tar|TAR).bz2(-.)'
elif [[ "$1" = *J* ]]; then
_files "$expl[@]" -g '*.(tar|TAR).(lzma|xz)(-.)'
- elif [[ "$_cmd_variant[$service]" == gnu ]]; then
+ elif [[ "$_cmd_variant[$service]" == (gnu|libarchive) ]]; then
_files "$expl[@]" -g '*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)'
else
_files "$expl[@]" -g '*.(tar|TAR)(-.)'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author