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

Re: [PATCH] Completion batch #5: Simple Darwin and Linux utilities



dana wrote:
> New functions for simple utilities belonging to the 'Darwin' and 'Linux' groups.

Thanks, I've committed these.

That is with the exception of Linux/Command/_ldd – there's already a
completion for ldd in Unix/Command that also handles Solaris and the
BSDs. ldconfig also exists outside of Linux but in a different form so
may need moving later.

> +[[ $state == variables-* ]] && {
> +  tmp=( ${${(f)"$( command $service -p )"}%%[[:space:]]*} )

Ideally, you should use _call_program when calling external commands as
that allows the program to be disabled or overridden. It is also better
in general to use $words[1] instead of $service in case a command is
specified by the user with a full path and there's another version of
the command elsewhere in $PATH.

> +#compdef plutil

> +local -a context line state state_descr tmp fmts=( xml1 binary1 json )

> +_arguments -s -S : \

> +  '(-convert -extract -replace -remove)-insert[insert value at specified key path into property list]: :->k: :->t: :->v' \

> +    _values 'value type' $tmp && ret=0

To elaborate on what I was explaining with contexts, after completion with:
  plutil -insert <tab>

_arguments will set context=( set2-option-insert-1 )
The idea is that when looking up styles with zstyle, this should be
included. Unlike _wanted, _alternative, _tags and others, this can't be
passed on to _values other than in $curcontext. So in this case, using
_arguments -C might be better.

> +# Don't complete host names unless we have -r (this is weird, but the obvious
> +# alternative (exclusion sets) currently doesn't work properly with option
> +# stacking)

Can you elaborate on what doesn't work here? Sets have some oddities and
are often better avoided.

Oliver



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