Subject: Re: 1.5.21: bash-completion 20060301-1 failure
From: Hans <[email-masked]>
To: Eric Blake <[email-masked]>
Cc: [email-masked]
Date: Mon, 31 Jul 2006 11:11:52 -0400

Thank you for your reply.  I apologize for the misleading description
of the syntax of my command.  I meant that I type '$ ssh xyz' where
'xyz' is the first few letters of one of my known hosts, and then I
press Tab.  It should then complete the host name, right?

I am including below the output after '$ set -xv'.  I have
'demons.hell.com,666.666.666.666' in ~/.ssh/known_hosts , and I then
type '$ ssh demons' and press tab.  (Of course, I have modified my
actual host and directory names.  Note also: 'demons.hell.com' is the
unique host name in the file that begins with 'demons'.)

-- Begin Clip --

$ ssh demons+ local cur prev
+ local -a config
+ COMPREPLY=()
+ cur=demons
+ prev=ssh
+ case "$prev" in
+ _known_hosts -a
+ local cur curd ocur user suffix aliases global_kh user_kh hosts i host
+ local -a kh khd config
+ COMPREPLY=()
+ cur=demons
+ ocur=demons
+ '[' -a = -a ']'
+ aliases=yes
+ '[' -a = -c ']'
+ '[' '' = -c ']'
+ [[ demons == *@* ]]
+ kh=()
+ '[' -r /etc/ssh/ssh_config ']'
+ '[' -r '/home/David Hasselhoff/.ssh/config' ']'
+ '[' -r '/home/David Hasselhoff/.ssh2/config' ']'
+ '[' 0 -gt 0 ']'
+ '[' -r '' ']'
+ '[' -r /etc/ssh/ssh_known_hosts ']'
+ '[' -r /etc/ssh/ssh_known_hosts2 ']'
+ '[' -r /etc/known_hosts ']'
+ '[' -r /etc/known_hosts2 ']'
+ '[' -d /etc/ssh2/knownhosts ']'
+ '[' -r '' ']'
+ '[' -r '/home/David Hasselhoff/.ssh/known_hosts' ']'
+ kh=(${kh[@]} ~/.ssh/known_hosts)
+ '[' -r '/home/David Hasselhoff/.ssh/known_hosts2' ']'
+ '[' -d '/home/David Hasselhoff/.ssh2/hostkeys' ']'
+ '[' 1 -gt 0 -o 0 -gt 0 ']'
+ cur=demons
+ cur=demons
+ curd=demons
+ [[ demons == [0-9]*.* ]]
+ [[ demons == [0-9]* ]]
+ '[' -z demons ']'
+ cur='^demons'
+ '[' 1 -gt 0 ']'
+ COMPREPLY=($( awk 'BEGIN {FS=","}
                                {for (i=1; i<=2; ++i) { \
                                       gsub(" .*$", "", $i); \
                                       if ($i ~ /'$cur'/) {print $i} \
                                }}' ${kh[@]} 2>/dev/null ))
 awk 'BEGIN {FS=","}
                                {for (i=1; i<=2; ++i) { \
                                       gsub(" .*$", "", $i); \
                                       if ($i ~ /'$cur'/) {print $i} \
                                }}' ${kh[@]} 2>/dev/null 
++ awk 'BEGIN {FS=","}
                                {for (i=1; i<=2; ++i) { \
                                       gsub(" .*$", "", $i); \
                                       if ($i ~ /^demons/) {print $i} \
                                }}' /home/David Hasselhoff/.ssh/known_hosts
+ '[' 0 -gt 0 ']'
+ '[' 0 -gt 0 ']'
+ (( i=0 ))
+ (( i < 0 ))
+ return 0
+ '[' 1 -eq 1 ']'
+ return 0

-- End Clip --

By the way, I seem even to have trouble simply autocompleting the
filename '/home/David Hasselhoff/.ssh/known_hosts'.  Here is some output:

-- Begin Clip --

$ cd /home/David\ Hasselhoff/.ssh/know+ local 'IFS=
' 'cur=/home/David\ Hasselhoff/.ssh/know' i j k
+ [[ /home/David\ Hasselhoff/.ssh/know == ?(\\)\$* ]]
+ '[' -z '' ']'
+ _filedir -d
+ local 'IFS=
' xspec
+ _expand
+ '[' '/home/David\ Hasselhoff/.ssh/know' '!=' '/home/David\ Hasselhoff/.ssh/know' ']'
+ [[ /home/David\ Hasselhoff/.ssh/know == \~*/* ]]
+ [[ /home/David\ Hasselhoff/.ssh/know == \~* ]]
+ '[' -d = -d ']'
+ COMPREPLY=(${COMPREPLY[@]:-} $( compgen -d -- $cur ))
 compgen -d -- $cur 
++ compgen -d -- '/home/David\ Hasselhoff/.ssh/know'
+ return 0
+ return 0

-- End Clip -- 

I should also add that completion *does* work on known_hosts with scp.

Thanks,
Hans

At Mon, 31 Jul 2006 06:42:13 -0600,
Eric Blake wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> According to Hans on 7/29/2006 7:09 PM:
> > I'm having some trouble with bash-completion.  For example, it does
> > not complete ssh commands from my known_hosts file.
> 
> > I have also tried sourcing it from within a bash session.  In both
> > cases, if I type
> > 
> > $ ssh hostname... [tab]
> > 
> > it does nothing.
> 
> You can use 'set -xv' to turn on verbose processing of what is happening
> when you hit TAB, to see if something jumps out at you as the culprit.  At
> any rate, this sounds like an upstream problem with bash-completion, not
> cygwin-specific.  And my quick check of 'ssh [TAB]' worked for me.  Since
> your example of 'ssh hostname... [TAB]' is not valid syntax for ssh, I
> can't tell what you were expecting.  Post a real example/screenshot
> (although you may edit machine names if you are worried about that) if you
> expect more help.
> 
> - --
> Life is short - so eat dessert first!
> 
> Eric Blake             [email-masked]
> volunteer cygwin bash-completion maintainer
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.1 (Cygwin)
> Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFEzfqk84KuGfSFAYARAq/CAJ93+UBshM9QnmAmmaJQTFhX72SThgCeN3YS
> nM1wTblpKNrjkHSq1hS7SMM=
> =x1Sy
> -----END PGP SIGNATURE-----

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/