summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorKoichi Murase <myoga.murase@gmail.com>2025-06-04 11:25:49 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-06-09 21:46:53 +0900
commitadc9ad28da1fc5b6e7a4b5916442ccf9aa166817 (patch)
treeeba96aeff6401d890d1f9351e059001b15d807a6 /shell
parent585cfaef8b9292f67177388f24f1514fcdd44f09 (diff)
downloadfzf-adc9ad28da1fc5b6e7a4b5916442ccf9aa166817.tar.gz
[bash,zsh] Correctly exclude the hostname "0.0.0.0"
In the current implementation, any hostnames in /etc/hosts containing "0.0.0.0" as a part (such as "110.0.0.0" would be excluded. "0.0.0.0" should be checked by the exact match.
Diffstat (limited to 'shell')
-rw-r--r--shell/completion.bash5
-rw-r--r--shell/completion.zsh5
2 files changed, 6 insertions, 4 deletions
diff --git a/shell/completion.bash b/shell/completion.bash
index 7e46bacf..c489c5a0 100644
--- a/shell/completion.bash
+++ b/shell/completion.bash
@@ -516,11 +516,12 @@ if ! declare -F __fzf_list_hosts > /dev/null; then
# Note: mawk <= 1.3.3-20090705 does not support the POSIX brackets of
# the form [[:blank:]], and Ubuntu 18.04 LTS still uses this
# 16-year-old mawk unfortunately. We need to use [ \t] instead.
- /^[ \t]*(#|$)|0\.0\.0\.0/ { next }
+ /^[ \t]*(#|$)/ { next }
{
sub(/#.*/, "")
for (i = 2; i <= NF; i++)
- print $i
+ if ($i != "0.0.0.0")
+ print $i
}
' /etc/hosts 2> /dev/null
)
diff --git a/shell/completion.zsh b/shell/completion.zsh
index 3663a610..e0227007 100644
--- a/shell/completion.zsh
+++ b/shell/completion.zsh
@@ -294,11 +294,12 @@ if ! declare -f __fzf_list_hosts > /dev/null; then
# Note: mawk <= 1.3.3-20090705 does not support the POSIX brackets of
# the form [[:blank:]], and Ubuntu 18.04 LTS still uses this
# 16-year-old mawk unfortunately. We need to use [ \t] instead.
- /^[ \t]*(#|$)|0\.0\.0\.0/ { next }
+ /^[ \t]*(#|$)/ { next }
{
sub(/#.*/, "")
for (i = 2; i <= NF; i++)
- print $i
+ if ($i != "0.0.0.0")
+ print $i
}
' /etc/hosts 2> /dev/null
)