mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 04:43:10 +00:00
use getent for hosts if available, otherwise use more resilient processing of /etc/hosts
This commit is contained in:
parent
8253df7c3d
commit
165ba535f0
1 changed files with 4 additions and 2 deletions
|
@ -2,8 +2,10 @@
|
|||
function __fish_print_hostnames -d "Print a list of known hostnames"
|
||||
|
||||
# Print all hosts from /etc/hosts
|
||||
if test -f /etc/hosts
|
||||
sed </etc/hosts -e 's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed -e 's/\#.*//'|tr \t \n |sgrep -v '^$'
|
||||
if test -x /usr/bin/getent
|
||||
getent hosts | tr -s ' ' ' ' | cut -d ' ' -f 2- | tr ' ' '\n'
|
||||
elseif test -f /etc/hosts
|
||||
tr -s ' \t' ' ' < /etc/hosts | sed 's/ *#.*//' | cut -s -d ' ' -f 2- | grep -o '[^ ]*'
|
||||
end
|
||||
# Print nfs servers from /etc/fstab
|
||||
if test -f /etc/fstab
|
||||
|
|
Loading…
Reference in a new issue