[Bash-completion-devel] _filedir only escaping whitespace when `-o filenames' is in effect?

Freddy Vulto fvulto at gmail.com
Mon Jul 27 21:00:24 UTC 2009


I just noticed `ssh -F <TAB>' doesn't escape spaces in filenames.
Further investigation showes that _filedir only works if `-o
filenames' is in effect:

    $ touch 'a b'
    $ _foo() { cur=$(_get_cword); _filedir; }
    $ complete -F _foo foo
    $ foo a<TAB>
    $ foo a b  # Incorrect, space isn't escaped
    $ complete -o filenames -F _foo foo
    $ foo a<TAB>
    $ foo a\ b  # This is correct

I was under the assumption that `_filedir' was to be trusted
anywhere, but it seems it isn't or am I overlooking something?
Otherwise, wouldn't it be nice to add an option to `_filedir' to
escape spaces?  Or better, create a new function `_compgen_filedir'
with this optional behaviour ;-)?  At least the following
completions have the same problem at the point where they call
`_filedir', because they don't have `-o filenames' ($filenames) in
effect:

    ../bash-completion/contrib$ for f in $(grep -l _filedir *)
    > do
    > grep -L \$filenames $f
    > done
    aptitude
    bitkeeper
    bittorrent
    bluez-utils
    cfengine
    cksfv
    clisp
    cpan2dist
    cpio
    dhclient
    dsniff
    freeciv
    gcl
    gkrellm
    gpg
    gpg2
    heimdal
    lilo
    lisp
    lvm
    minicom
    mkinitrd
    munin-node
    ntpdate
    openldap
    openssl
    rpmcheck
    samba
    sbcl
    screen
    smartctl
    strace
    tcpdump
    update-alternatives
    vncviewer
    vpnc
    wvdial
    xm

Regards, Freddy



More information about the Bash-completion-devel mailing list