Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: _tar (autodetection of compression by GNU tar >= 1.14.91)



> 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#-}"



Messages sorted by: Reverse Date, Date, Thread, Author