[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
Sat Dec 3 17:40:49 UTC 2011


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

>Status: Closed
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: Won't Fix
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


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

>Comment By: Ville Skyttä  (scop-guest)
Date: 2011-12-03 19:40

Message:
I think the current behavior is fine.  It's not unreasonable to expect that one may want to ssh to both "myexample" and "example.org" -- I know I have an ssh config setup where I do want that.

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

Comment By: Igor Murzov (garik-guest)
Date: 2011-11-05 05:10

Message:
I don't think it is a real bug. bash-completion has no intention to validate user input in any form, it just provides useful hints for the user. If user wants to type something insane, bash-completion won't try to stop him. I think, there is no point in discarding some variants that are useless most of the time, but could be useful in some situations. I think, it is the user who is responsible for the choice he made.

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

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