Skip to content

Commit 5de3148

Browse files
committed
fix(known_hosts): handle = separated ssh config options
1 parent f2be6ca commit 5de3148

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

bash_completion

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ _known_hosts_real()
17761776
# TODO(?): try to make known hosts files with more than one consecutive
17771777
# spaces in their name work (watch out for ~ expansion
17781778
# breakage! Alioth#311595)
1779-
tmpkh=($(awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u))
1779+
tmpkh=($(awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t=]+", "") { print $0 }' "${config[@]}" | sort -u))
17801780
IFS=$ifs
17811781
fi
17821782
if ((${#tmpkh[@]} != 0)); then
@@ -1860,7 +1860,7 @@ _known_hosts_real()
18601860

18611861
# append any available aliases from ssh config files
18621862
if [[ ${#config[@]} -gt 0 && -v aliases ]]; then
1863-
local -a hosts=($(command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\(.*\)$/\1/p' "${config[@]}"))
1863+
local -a hosts=($(command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]=]\{1,\}\(.*\)$/\1/p' "${config[@]}"))
18641864
if ((${#hosts[@]} != 0)); then
18651865
COMPREPLY+=($(compgen -P "$prefix" \
18661866
-S "$suffix" -W '${hosts[@]%%[*?%]*}' -X '\!*' -- "$cur"))

test/fixtures/_known_hosts_real/config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
# Unindented
44
Host gee* jar?this-part-we-do-not-complete-at-least-yet
55
HostName %h.example.com
6-
# Indented
7-
Host hus%%eth0 !negated #not-a-comment
6+
# Indented, with = separator
7+
Host = hus%%eth0 !negated #not-a-comment
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# With quotes and tilde
2-
UserKnownHostsFile "~/_known_hosts_real/known_hosts2"
1+
# With quotes and tilde, and =
2+
UserKnownHostsFile = "~/_known_hosts_real/known_hosts2"
33
# Without quotes, with tilde, and another on the same line
44
UserKnownHostsFile ~/_known_hosts_real/known_hosts3 _known_hosts_real/known_hosts4

0 commit comments

Comments
 (0)