* Teach 'tar' to support more file types
@ 2018-04-01 22:10 Eitan Adler
2018-04-05 3:55 ` Jun T
0 siblings, 1 reply; 4+ messages in thread
From: Eitan Adler @ 2018-04-01 22:10 UTC (permalink / raw)
To: Zsh hackers list
commit 61dba0a47a6a923a777c3a4c115af357ccf90396
Author: Eitan Adler <lists@eitanadler.com>
Date: Sun Apr 1 18:06:56 2018 -0400
Teach 'tar' to support more file types
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.
diff --git a/Completion/Unix/Type/_tar_archive
b/Completion/Unix/Type/_tar_archive
index 28df77638..8e8c45b12 100644
--- a/Completion/Unix/Type/_tar_archive
+++ b/Completion/Unix/Type/_tar_archive
@@ -20,10 +20,8 @@ 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
- _files "$expl[@]" -g
'*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)'
else
- _files "$expl[@]" -g '*.(tar|TAR)(-.)'
+ _files "$expl[@]" -g
'*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)'
fi
else
_files "$expl[@]"
--
Eitan Adler
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Teach 'tar' to support more file types
2018-04-01 22:10 Teach 'tar' to support more file types Eitan Adler
@ 2018-04-05 3:55 ` Jun T
2018-04-05 5:41 ` Baptiste Daroussin
2018-04-06 6:53 ` Eitan Adler
0 siblings, 2 replies; 4+ messages in thread
From: Jun T @ 2018-04-05 3:55 UTC (permalink / raw)
To: zsh-workers; +Cc: Eitan Adler
> 2018/04/02 7:10, Eitan Adler <lists@eitanadler.com> 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)(-.)'
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Teach 'tar' to support more file types
2018-04-05 3:55 ` Jun T
@ 2018-04-05 5:41 ` Baptiste Daroussin
2018-04-06 6:53 ` Eitan Adler
1 sibling, 0 replies; 4+ messages in thread
From: Baptiste Daroussin @ 2018-04-05 5:41 UTC (permalink / raw)
To: Jun T; +Cc: zsh-workers, Eitan Adler
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
On Thu, Apr 05, 2018 at 12:55:21PM +0900, Jun T wrote:
>
> > 2018/04/02 7:10, Eitan Adler <lists@eitanadler.com> 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'.
>
bsdtar 3.3.2 - libarchive 3.3.2 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6
yes :)
Bapt
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Teach 'tar' to support more file types
2018-04-05 3:55 ` Jun T
2018-04-05 5:41 ` Baptiste Daroussin
@ 2018-04-06 6:53 ` Eitan Adler
1 sibling, 0 replies; 4+ messages in thread
From: Eitan Adler @ 2018-04-06 6:53 UTC (permalink / raw)
To: Jun T; +Cc: Zsh hackers list
On 4 April 2018 at 20:55, Jun T <takimoto-j@kba.biglobe.ne.jp> wrote:
>
>> 2018/04/02 7:10, Eitan Adler <lists@eitanadler.com> 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'.
This patch LGTM.
--
Eitan Adler
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-04-06 6:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-01 22:10 Teach 'tar' to support more file types Eitan Adler
2018-04-05 3:55 ` Jun T
2018-04-05 5:41 ` Baptiste Daroussin
2018-04-06 6:53 ` Eitan Adler
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).