From f0d8d90ed1c2fee0696b0ee96759ee2299ce6651 Mon Sep 17 00:00:00 2001 From: David Adam Date: Mon, 29 Sep 2014 14:08:09 +0800 Subject: [PATCH] __fish_print_hostnames: use awk to process ssh_config files Uses awk rather than sed to account for multiple formatting options. Closes #1260. --- share/functions/__fish_print_hostnames.fish | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index 1ad431515..eadb21f59 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -18,11 +18,11 @@ function __fish_print_hostnames -d "Print a list of known hostnames" # Print hosts from system wide ssh configuration file if [ -e /etc/ssh/ssh_config ] - sgrep -Eoi '^ *host[^*]*$' /etc/ssh/ssh_config | cut -d ' ' -f 2 | tr ' ' '\n' | sgrep -v '[\*\?\!]' + awk -v FS="[ =]+" -v OFS='\n' 'tolower($0) ~ /^ *host[^*?!]*$/{ $1=""; print }' /etc/ssh/ssh_config end # Print hosts from ssh configuration file if [ -e ~/.ssh/config ] - sgrep -Eoi '^ *host[^*]*$' ~/.ssh/config | cut -d ' ' -f 2 | tr ' ' '\n' | sgrep -v '[\*\?\!]' + awk -v FS="[ =]+" -v OFS='\n' 'tolower($0) ~ /^ *host[^*?!]*$/{ $1=""; print }' ~/.ssh/config end end