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

Re: [PATCH] _xargs: add many options



On Sun, 21 Mar 2010 23:38:58 -0400 (EDT)
"Benjamin R. Haskell" <zsh@xxxxxxxxxx> wrote:
> 1. I suspect a lot of these are GNU-specific.  Can someone point me to a 
> good example of the use of _variant (sp?) for another command that has 
> both GNU- and non-GNU completion?

They're scattered through Completion/Unix/Command.  None of them are
particularly canonical, but the form "_pick_variant gnu=GNU unix --version"
is fairly common.  Searching for some component of "Free Software
Foundation" in the --version or --help output is also common, however since
xargs --version gives something like

GNU xargs version 4.2.31
Built using GNU gnulib version 2007-02-24

and --help doesn't give anything very useful, I think you need something
like the first form.

The only thing to be wary of in _pick_variant is if "<cmd> --version" might
be interpreted as "rm -rf /" or something else nasty if --version isn't
understood.  That's not a worry for xargs.

> What's the expected difference in behavior between an optspec of:
> 
> -optname[explanation]::
> 
> vs.
> 
> -optname:message:
> 
> ?

This is in the manual: the former documents the option itself, the second
documents its argument.  If the option has an argument the second form
should be present since otherwise you get no information about the argument
(from _arguments, anyway, if the completion defined in the arguments to
_arguments descends to another fully implemented completer instead of
e.g. specifying an array of possible values you may get information from
down there).  There's a style auto-description to use the second form to
document the option itself (it's not really clear this is useful as an
end-user option rather than an _arguments option except for the not very
helpful reason that people writing completions would forget to use it).
There's nothing to stop both forms from being present.

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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