bug-bash
[Top][All Lists]
Advanced

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

Re: "complete -o filenames" sometimes not working


From: Chet Ramey
Subject: Re: "complete -o filenames" sometimes not working
Date: Fri, 8 Nov 2024 12:48:11 -0500
User-agent: Mozilla Thunderbird

On 11/7/24 9:53 AM, Clark Wang wrote:
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.

OK. You asked for the completions to be treated as filenames. When
readline displays the possible completions for filenames, it doesn't
display the full pathname -- just the portion after the final slash.
The words with ProxyCommand= are trimmed to the portion after the
.../usr/bin/.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


reply via email to

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