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

Re: zle messes up 'words' variable?



2011/4/27 Jérémie Roquet <arkanosis@xxxxxxxxx>:
> 2011/4/27 Felipe Contreras <felipe.contreras@xxxxxxxxx>:
>> I'm trying the following:
>> ---
>> set_vars ()
>> {
>>        cur="foo"
>>        words="foo"
>>        cwords="foo"
>> }
>>
>> _foo ()
>> {
>>        local cur words cwords
>>        set_vars
>>
>>        echo "cur=${cur} words=${words} cwords=${cwords}" >> /tmp/comp_test.txt
>> }
>>
>> compdef _foo foo
>> ---
>>
>> Which results in:
>> cur=foo words= cwords=foo
>>
>> Strangely enough, if I use the #compdef tag, the code works fine (words="foo").
>>
>> Any ideas?
>
> $words is a special array used for completion. See `man zshcompsys'
> for more about it.

Yeah, I know that, but I'm overriding it, which works fine with
#compdef, but not with compdef. How do you explain that?

Besides, the problem is with bash completion emulation where 'words'
is not supposed to be special, so zsh is messing things up.

--
#!bash

autoload -U +X bashcompinit && bashcompinit

set_vars ()
{
	cur="foo"
	words="foo"
	cwords="foo"
}

_foo ()
{
	local cur words cwords
	set_vars

	echo "cur=${cur} words=${words} cwords=${cwords}" >> /tmp/comp_test.txt
}

complete -F _foo foo
--

-- 
Felipe Contreras



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