[Bash-completion-devel] Non-filename completions containing slashes and -o filenames
Ville Skyttä
ville.skytta at iki.fi
Tue May 26 15:55:15 UTC 2009
Hello,
I'm trying to figure out how to do the right thing with non-filename
completions containing slashes in a function that was passed to complete along
with -o filenames.
For example:
_foo()
{
COMPREPLY=( $( compgen -W 'a/b c/d e/f/g' -- ${COMP_WORDS[COMP_CWORD]} ) )
}
complete -F _foo -o filenames foo
a/b, c/d and e/f/g are *not* file/path names but other completions that just
happen to contain slashes. Whenever I wan't some of them, I don't want
file/dirname completion.
If I leave things as is in the above, "foo <TAB>" displays "b d g" whereas
I'd want "a/b c/d e/f/g" displayed _but_ for example "foo a<TAB>" properly
completes to "foo a/b " nevertheless. So it's just the display of available
completions that is wrong (everything up to and including the last slash is
missing).
If I remove "-o filenames", this simple example works as expected. But in
real life _foo() is not that simple and in many cases within it filename
completion is desired so it can't just be removed. I tried "compopt +o
filenames" with bash 4.x inside _foo() but that didn't help.
Ideas?
More information about the Bash-completion-devel
mailing list