[Bash-completion-devel] handling values with spaces
Igor Murzov
e-mail at date.by
Wed Sep 5 12:53:58 UTC 2012
On Tue, 04 Sep 2012 22:50:36 +0200
Guillaume Rousse <guillomovitch at gmail.com> wrote:
> My two latest completions handle list of values containing spaces:
> camera models for gphoto2, wifi networks essid for nmcli. I figured out
> how to redefine IFS for ensuring they are correctly suggested as
> possible completions, but this result in invalid command lines, such as:
> gphoto2 --camera Wi<TAB> ->
> gphoto2 --camera Wild Planet Digital Spy Camera 70137
>
> If I manually insert quotes, everything is OK:
> gphoto2 --camera "Wi<TAB> ->
> gphoto2 --camera "Wild Planet Digital Spy Camera 70137"
>
> I'd like to automatically either quote such values, or espace spaces
> through them, so as to produces valid command lines, such as:
> gphoto2 --camera "Wild Planet Digital Spy Camera 70137"
> gphoto2 --camera Wild\ Planet\ Digital\ Spy\ Camera\ 70137
>
> Is there any way to achieve this ?
I think that _filedir() does something similar to what you
want to do. It uses _quote_readline_by_ref() to quote strings.
-- Igor
More information about the Bash-completion-devel
mailing list