* PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91)
@ 2006-06-24 19:26 Clint Adams
2006-06-24 19:49 ` Bart Schaefer
0 siblings, 1 reply; 5+ messages in thread
From: Clint Adams @ 2006-06-24 19:26 UTC (permalink / raw)
To: zsh-workers
Since version 1.14.91, GNU tar has autodetected compressed
archives.
Index: Completion/Unix/Command/_tar
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_tar,v
retrieving revision 1.3
diff -u -r1.3 _tar
--- Completion/Unix/Command/_tar 27 Feb 2003 09:29:26 -0000 1.3
+++ Completion/Unix/Command/_tar 24 Jun 2006 19:24:54 -0000
@@ -21,6 +21,8 @@
# from some of the possible long options, and from the second word if
# that does not start with a hyphen.
+_pick_variant gnu=GNU unix --version
+
tmp=("${(@M)words:#-[^-]*}")
_tar_cmd="${(j::)tmp#-}"
Index: Completion/Unix/Type/_tar_archive
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_tar_archive,v
retrieving revision 1.3
diff -u -r1.3 _tar_archive
--- Completion/Unix/Type/_tar_archive 21 Jan 2004 13:53:29 -0000 1.3
+++ Completion/Unix/Type/_tar_archive 24 Jun 2006 19:24:54 -0000
@@ -18,6 +18,8 @@
_files "$expl[@]" -g '*.((tar|TAR).(gz|GZ|Z)|tgz)(-.)'
elif [[ "$1" = *[Ijy]* ]]; then
_files "$expl[@]" -g '*.(tar|TAR).bz2(-.)'
+ elif [[ "$_cmd_variant[$service]" == gnu ]]; then
+ _files "$expl[@]" -g '*.((tar|TAR).(gz|GZ|Z|bz2)|tgz)(-.)'
else
_files "$expl[@]" -g '*.(tar|TAR)(-.)'
fi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91)
2006-06-24 19:26 PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91) Clint Adams
@ 2006-06-24 19:49 ` Bart Schaefer
2006-06-24 20:14 ` Clint Adams
0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2006-06-24 19:49 UTC (permalink / raw)
To: zsh-workers
On Jun 24, 3:26pm, Clint Adams wrote:
}
} Since version 1.14.91, GNU tar has autodetected compressed
} archives.
I'm not entirely certain this patch is a good idea. It doesn't
really hurt to have a completer offer things like command-line
options for the latest version of a program, but to complete a
file that an older version won't know what to do with is a bit
worse.
What proportion of zsh users can be expected to have the latest
version of tar? There is not one single machine where I use zsh
where this completion would be correct, because all of them have
GNU tar but the latest is 1.14.10 (and most are much older).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91)
2006-06-24 19:49 ` Bart Schaefer
@ 2006-06-24 20:14 ` Clint Adams
2006-06-25 4:24 ` Bart Schaefer
2006-06-26 14:28 ` Oliver Kiddle
0 siblings, 2 replies; 5+ messages in thread
From: Clint Adams @ 2006-06-24 20:14 UTC (permalink / raw)
To: zsh-workers
> I'm not entirely certain this patch is a good idea. It doesn't
> really hurt to have a completer offer things like command-line
> options for the latest version of a program, but to complete a
> file that an older version won't know what to do with is a bit
> worse.
How about this?
Index: Completion/Unix/Command/_tar
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_tar,v
retrieving revision 1.4
diff -u -r1.4 _tar
--- Completion/Unix/Command/_tar 24 Jun 2006 19:28:55 -0000 1.4
+++ Completion/Unix/Command/_tar 24 Jun 2006 20:13:34 -0000
@@ -21,7 +21,13 @@
# from some of the possible long options, and from the second word if
# that does not start with a hyphen.
-_pick_variant gnu=GNU unix --version
+if _pick_variant gnu=GNU unix --version; then
+ case "$($service --version)" in
+ (tar \(GNU tar\) (#b)([0-9.-]##)*)
+ is_at_least 1.14.91 "$match[1]" || _cmd_variant[$service]="gnu-old"
+ ;;
+ esac
+fi
tmp=("${(@M)words:#-[^-]*}")
_tar_cmd="${(j::)tmp#-}"
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91)
2006-06-24 20:14 ` Clint Adams
@ 2006-06-25 4:24 ` Bart Schaefer
2006-06-26 14:28 ` Oliver Kiddle
1 sibling, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2006-06-25 4:24 UTC (permalink / raw)
To: zsh-workers
On Jun 24, 4:14pm, Clint Adams wrote:
}
} How about this?
Except that is_at_least may not be autoloaded yet at that point, it
looks OK. (I like the trick of putting a backreference in the case
pattern.)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91)
2006-06-24 20:14 ` Clint Adams
2006-06-25 4:24 ` Bart Schaefer
@ 2006-06-26 14:28 ` Oliver Kiddle
1 sibling, 0 replies; 5+ messages in thread
From: Oliver Kiddle @ 2006-06-26 14:28 UTC (permalink / raw)
To: zsh-workers
Clint Adams wrote:
>
> How about this?
> + is_at_least 1.14.91 "$match[1]" || _cmd_variant[$service]="gnu-old"
You should use the -r option to _pick_variant. The use of the
_cmd_variant associative array for a cache is really an internal
implementation detail of _pick_variant. Also, if we ever have
namespaces, it'd be renamed.
Oliver
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-06-26 14:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-24 19:26 PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91) Clint Adams
2006-06-24 19:49 ` Bart Schaefer
2006-06-24 20:14 ` Clint Adams
2006-06-25 4:24 ` Bart Schaefer
2006-06-26 14:28 ` Oliver Kiddle
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).