Skip to content
Myr

[bash,zsh] Do not end the hostname analysis on "]" in ~/.ssh/known_hosts

Before adoption: this commit came in with the history the project adopted, so no landing records it.

An entry of the form `[example.com]:port,192.168.0.1 ...` in ~/.ssh/known_hosts are not properly processed. The current implementation gives up the matching on the first occurrence of `]`, the subsequent 192.168.0.1 would not be extracted. This patch continues the analysis and removes "]" together with "[". This patch also removes the ":port" part from the hostnames in ~/.ssh/known_hosts. One cannot use the form "hostname:port" in the arguments to the ssh command anyway.

authored by Koichi Murase · committed by Junegunn Choi · parent b5cd888 · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:shell/completion.bash+2 added-2 removed
501 unmodified lines
502 ' ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null503 ) \504 <(505 __fzf_exec_awk -F ',' '506 match($0, /^[[a-zA-Z0-9.,:-]+/) {506 match($0, /^[][a-zA-Z0-9.,:-]+/) {507 $0 = substr($0, 1, RLENGTH)508 gsub(/\[/, "")508 gsub(/[][]|:[^,]*/, "")509 for (i = 1; i <= NF; i++)510 print $i511 }512 ' ~/.ssh/known_hosts 2> /dev/null
173 unmodified lines
modified:shell/completion.zsh+2 added-2 removed
279 unmodified lines
280 ' ~/.ssh/config ~/.ssh/config.d/* /etc/ssh/ssh_config 2> /dev/null281 ) \282 <(283 __fzf_exec_awk -F ',' '284 match($0, /^[[a-zA-Z0-9.,:-]+/) {284 match($0, /^[][a-zA-Z0-9.,:-]+/) {285 $0 = substr($0, 1, RLENGTH)286 gsub(/\[/, "")286 gsub(/[][]|:[^,]*/, "")287 for (i = 1; i <= NF; i++)288 print $i289 }290 ' ~/.ssh/known_hosts 2> /dev/null
180 unmodified lines