mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
use getent for hosts if available, otherwise use more resilient processing of /etc/hosts
This commit is contained in:
parent
8253df7c3d
commit
165ba535f0
@ -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…
x
Reference in New Issue
Block a user