aboutsummaryrefslogtreecommitdiffhomepage
path: root/init
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-02-03 10:41:14 +1000
committerGravatar axel <axel@liljencrantz.se>2006-02-03 10:41:14 +1000
commit19c67db731074a65bef853674180ff3c5f55b460 (patch)
tree083bbd8215f4155b2ddb9ffb662e1105a7c87a70 /init
parent294da72d11a2ab454d484ab6a2deb868d6a262cb (diff)
Make hostname completion code more robust
darcs-hash:20060203004114-ac50b-54fda8fe89649d404cd6981d7783e18f5092f217.gz
Diffstat (limited to 'init')
-rw-r--r--init/fish_complete.fish.in9
1 files changed, 6 insertions, 3 deletions
diff --git a/init/fish_complete.fish.in b/init/fish_complete.fish.in
index f892394a..4d160b79 100644
--- a/init/fish_complete.fish.in
+++ b/init/fish_complete.fish.in
@@ -140,10 +140,13 @@ end
function __fish_print_hostnames -d "Print a list of known hostnames"
# Print all hosts from /etc/hosts
- cat /etc/hosts|sed -e 's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed -e 's/\#.*//'|sed -e 'y/\t/\n/'|grep -v '^$'
-
+ if test -f /etc/hosts
+ sed </etc/hosts -e 's/[0-9.]*\( \|\t\)*\(.*\)/\2/'|sed -e 's/\#.*//'|tr \t \n |grep -v '^$'
+ end
# Print nfs servers from /etc/fstab
- cat /etc/fstab| grep "^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\|[a-zA-Z.]*\):"|cut -d : -f 1
+ if test -f /etc/fstab
+ grep </etc/fstab "^\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\|[a-zA-Z.]*\):"|cut -d : -f 1
+ end
# Print hosts with known ssh keys
cat ~/.ssh/known_hosts{,2} ^/dev/null|cut -d ' ' -f 1| cut -d , -f 1