mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-01 00:02:00 +08:00
fix trailing comments in __fish_print_hostnames
/etc/hosts specifies, that everything after a #-character is to be treated as a comment. The current __fish_print_hostnames however only considers #-characters at the beginning of a line. Thus the comment from following valid hosts-entry would end up in the completion output: 1.2.3.4 myhost # examplecomment getent hosts properly handles comments.
This commit is contained in:
parent
e2fda67439
commit
d9ee5d3863
|
@ -8,13 +8,13 @@ function __fish_print_hostnames -d "Print a list of known hostnames"
|
|||
# `/etc/hosts` for portability reasons.
|
||||
|
||||
begin
|
||||
test -r /etc/hosts && read -z </etc/hosts
|
||||
test -r /etc/hosts && read -z </etc/hosts | string replace -r '#.*$' ''
|
||||
or type -q getent && getent hosts 2>/dev/null
|
||||
end |
|
||||
# Ignore comments, own IP addresses (127.*, 0.0[.0[.0]], ::1), non-host IPs (fe00::*, ff00::*),
|
||||
# Ignore own IP addresses (127.*, 0.0[.0[.0]], ::1), non-host IPs (fe00::*, ff00::*),
|
||||
# and leading/trailing whitespace. Split results on whitespace to handle multiple aliases for
|
||||
# one IP.
|
||||
string replace -irf '^\s*?(?!(?:#|0\.|127\.|ff0|fe0|::1))\S+\s*(.*?)\s*$' '$1' |
|
||||
string replace -irf '^\s*?(?!(?:0\.|127\.|ff0|fe0|::1))\S+\s*(.*?)\s*$' '$1' |
|
||||
string split ' '
|
||||
|
||||
# Print nfs servers from /etc/fstab
|
||||
|
|
Loading…
Reference in New Issue
Block a user