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

Re: dumb completion question



Andy Spiegl wrote:
> # compdef cssh crsh
> 
> local definedclusters
> definedclusters=(all www fire db mail web rest)
> 
> _arguments \
>   '-h[help]' \
> ...
>   '*:cssh clusters:($definedclusters)'
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 
> So far so good, but if I read in the variable dynamically
> (which is what I want of course :-), like this:
>  definedclusters="($(grep ^clusters $HOME/.csshrc | cut -d= -f2- 2>/dev/null)
> )"
> 
> then I get _very_ strange results: after pressing TAB I don't see the content
> s
> of the variable definedclusters but stuff from my .Xdefaults and .zsh.history
> !

If you have extendedglob set, you need to qutoe '^clusters' or it will
expand to all files apart from one called clusters, so you will be
grepping all those files plus ~/.csshrc for the first file in the
directory.

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


.



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