[Bash-completion-devel] [bash-completion-Bugs][313404] ssh completion should ignore "HostName" in ssh config

bash-completion-bugs at alioth.debian.org bash-completion-bugs at alioth.debian.org
Wed Oct 26 07:48:08 UTC 2011


Bugs item #313404, was opened at 2011-10-26 09:48 by Thomas Wouters
You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=313404&group_id=100114

Status: Open
Priority: 3
Submitted By: Thomas Wouters (beli-guest)
Assigned to: Nobody (None)
Summary: ssh completion should ignore "HostName" in ssh config 
Distribution: None
Originally reported in: None
Milestone: None
Status: None
Original bug number: 


Initial Comment:
Ssh completion shouldn't include HostName values from ssh config.
I think this beats the purpose of defining hosts in an ssh config.

For example, ~/.ssh/config:

Host myexample
    HostName example.org
    Port 222
    User someuser

Bash completion completes both "myexample" and "example.org".
The thing is that ssh won't use port 222 or someuser as user when you ssh to "example.org" in stead of "myexample".

It seems better to just ignore HostName. As far as I know, this is also how zsh completion does it.

A possible fix:

--- /etc/bash_completion	2011-02-11 23:34:25.000000000 +0100
+++ bash_completion.new	2011-10-26 09:45:10.815174614 +0200
@@ -1334,7 +1334,7 @@
 
     # append any available aliases from config files
     if [[ ${#config[@]} -gt 0 && -n "$aliases" ]]; then
-        local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]\([Nn][Aa][Mm][Ee]\)\{0,1\}['"$'\t '"']\{1,\}\([^#*?]*\)\(#.*\)\{0,1\}$/\2/p' "${config[@]}" )
+        local hosts=$( sed -ne 's/^[ \t]*[Hh][Oo][Ss][Tt]['"$'\t '"']\+\([^#*?]*\)\(#.*\)\{0,1\}$/\1/p' "${config[@]}" )
         COMPREPLY=( "${COMPREPLY[@]}" $( compgen  -P "$prefix$user" \
             -S "$suffix" -W "$hosts" -- "$cur" ) )
     fi


----------------------------------------------------------------------

You can respond by visiting: 
https://alioth.debian.org/tracker/?func=detail&atid=413095&aid=313404&group_id=100114



More information about the Bash-completion-devel mailing list