[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Multiple Words on Bash Programmable Auto Completion
From: |
Daniel Fleischman |
Subject: |
Multiple Words on Bash Programmable Auto Completion |
Date: |
Wed, 1 Oct 2008 23:56:30 -0300 |
Description:
I don't know if this is a bug or not, but it has to do with programmable
auto completion. Whenever the options have multiple words I don't get what I
want.
Here is an example, just for show:
f() {
COMPREPLY=""
c=0
while read line; do
COMPREPLY[$c]=$line
c=$[$c + 1]
done <<< "$(compgen -W "a\ b a\ b\ c b" --
${COMP_WORDS[COMP_CWORD]})"
}
complete -F f lala
now watch this:
daniel@fermento ~ $ lala <TAB><TAB>
a b a b c b
daniel@fermento ~ $ lala
This is what I expected, but now, if I do:
daniel@fermento ~ $ lala a<TAB>
I will get:
daniel@fermento ~ $ lala a b
while I expected
daniel@fermento ~ $ lala a\ b
as auto-completion normaly does with file names.
I "fixed" this by changing one line of the function f. The new line is:
COMPREPLY[$c]=${line// /\\ }
But now, I get this:
daniel@fermento ~ $ lala <TAB><TAB>
a\ b a\ b\ c b
daniel@fermento ~ $ lala
So, what I want to know is: is there any way to have the spaces escaped
when completing a word, but not when showing the completion options
(COMPREPLY)?
If so, please, tell me how. If not, well, I've found a bug :P
Thank you in advance,
Daniel Fleischman.
Repeat-By:
1) Type the "f" function
2) write "lala a<TAB>" on bash
- Multiple Words on Bash Programmable Auto Completion,
Daniel Fleischman <=