[Bash-completion-devel] [SCM] bash-completion branch, master, updated. 1.3-357-gc7e2640
Ville Skyttä
ville.skytta at iki.fi
Sat Jun 18 14:06:04 UTC 2011
On 06/12/2011 01:57 PM, Raphaël wrote:
> Isn't the comp option alive between invocations ?
Not when set for the currently executing completion, see compopt in the
bash man page.
$ _foo() { echo; compopt; compopt -o nospace; compopt; }
$ complete -F _foo foo
$ foo <TAB>
compopt +o bashdefault +o default +o dirnames +o filenames +o nospace +o
plusdirs foo
compopt +o bashdefault +o default +o dirnames +o filenames -o nospace +o
plusdirs foo
$ foo <TAB>
compopt +o bashdefault +o default +o dirnames +o filenames +o nospace +o
plusdirs foo
compopt +o bashdefault +o default +o dirnames +o filenames -o nospace +o
plusdirs foo
>> Shouldn't the compopt -o nospace be done only for completions that end
>> with a "="? I.e. move it after COMPREPLY=(...) and do
>> [[ $COMPREPLY == *= ]] && compopt -o nospace
>
> sure it should !
> I now understand better this idiom.
> But is it really equivalent to:
> ${#COMPREPLY[@]} -eq 1 && ${COMPREPLY[0]} == *=
If it guards "compopt -o nospace", I don't see why it wouldn't be.
If there are more than one completions, nospace has no effect. And
${COMPREPLY[0]} is equivalent to $COMPREPLY, see "Arrays" in the bash
man page.
More information about the Bash-completion-devel
mailing list