[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Non-filename completions containing slashes and -o filenames

From: Ville Skyttä
Subject: Non-filename completions containing slashes and -o filenames
Date: Tue, 9 Jun 2009 00:10:16 +0300
User-agent: KMail/1.11.3 (Linux/; KDE/4.2.3; x86_64; ; )


Apologies if this is not an appropriate list to post a question like this 
(pointers elsewhere welcome), but here goes:

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:

  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 want 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 from my POV (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 other 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, and anyway I'm 
looking for a solution that would preferably work at least with bash 3.x, if 
not 2.05+ (for the bash-completion project at http://bash-

Ideas?  Please Cc me in replies, I'm not subscribed to bug-bash at the moment.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]