bug-bash
[Top][All Lists]
Advanced

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

"complete -o filenames" sometimes not working


From: Clark Wang
Subject: "complete -o filenames" sometimes not working
Date: Thu, 7 Nov 2024 22:53:40 +0800

See the following reproduce example:

$ cat ssh_compspec
COMP_WORDBREAKS=${COMP_WORDBREAKS//[=:]/}

function _ssh()
{
    local cur="$2" pre="$3"
    local options=(
        ProxyCommand='/usr/bin/nc -x host:port %h %p -X 5'
        ProxyCommand='/usr/bin/nc -x host:port %h %p -X connect'
        ConnectTimeout=10 )
    local i saveIFS="$IFS"

    if [[ $pre == '-o' ]]; then
        for ((i=0; i < ${#options[@]}; ++i)); do
            options[i]=$( printf '%q' "${options[i]}" )
        done

        IFS=$'\n'
        COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) )
        IFS=$saveIFS
    fi
}

complete -F _ssh -o filenames ssh
$ . ./ssh_compspec

Then,

$ ssh -o <Tab><Tab>
ConnectTimeout=10                 nc -x host:port %h %p -X 5        nc -x
host:port %h %p -X connect

As we can see, "ProxyCommand" is missing.

But this works fine:

$ ssh -o P<Tab>
$ ssh -o ProxyCommand=/usr/bin/nc\ -x\ host:port\ %h\ %p\ -X\


reply via email to

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