summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorKoichi Murase <myoga.murase@gmail.com>2025-06-03 21:30:56 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-09 21:46:53 +0900
commit585cfaef8b9292f67177388f24f1514fcdd44f09 (patch)
treecff7de84098018309d62aad10b6c594a940bc9c0 /shell
parentb5cd8880b1e2884ad928beb9ab3fd21a599cc446 (diff)
downloadfzf-585cfaef8b9292f67177388f24f1514fcdd44f09.tar.gz
[bash,zsh] Do not end the hostname analysis on "]" in ~/.ssh/known_hosts
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.
Diffstat (limited to 'shell')
-rw-r--r--shell/completion.bash4
-rw-r--r--shell/completion.zsh4
2 files changed, 4 insertions, 4 deletions
diff --git a/shell/completion.bash b/shell/completion.bash
index afe19c25..7e46bacf 100644
--- a/shell/completion.bash
+++ b/shell/completion.bash
@@ -503,9 +503,9 @@ if ! declare -F __fzf_list_hosts > /dev/null; then
) \
<(
__fzf_exec_awk -F ',' '
- match($0, /^[[a-zA-Z0-9.,:-]+/) {
+ match($0, /^[][a-zA-Z0-9.,:-]+/) {
$0 = substr($0, 1, RLENGTH)
- gsub(/\[/, "")
+ gsub(/[][]|:[^,]*/, "")
for (i = 1; i <= NF; i++)
print $i
}
diff --git a/shell/completion.zsh b/shell/completion.zsh
index b17271c5..3663a610 100644
--- a/shell/completion.zsh
+++ b/shell/completion.zsh
@@ -281,9 +281,9 @@ if ! declare -f __fzf_list_hosts > /dev/null; then
) \
<(
__fzf_exec_awk -F ',' '
- match($0, /^[[a-zA-Z0-9.,:-]+/) {
+ match($0, /^[][a-zA-Z0-9.,:-]+/) {
$0 = substr($0, 1, RLENGTH)
- gsub(/\[/, "")
+ gsub(/[][]|:[^,]*/, "")
for (i = 1; i <= NF; i++)
print $i
}