From b89a6451a3f18589750864e3709d24bb307b484a Mon Sep 17 00:00:00 2001 From: Akatsuki <3736910+akiirui@users.noreply.github.com> Date: Sun, 27 Oct 2019 00:17:52 +0800 Subject: [PATCH] functions/__fish_print_hostnames: Fix ssh_configs no values return (#6236) * functions/__fish_print_hostnames: Fix ssh_configs no values return `string replace` not working with mutlilines variable. So split per line first. * functions/__fish_print_hostnames: remove quotes at `split '\n'` "\n with quotes" will cause `string split` weird issues. * functions/__fish_print_hostnames: using `read -alz -d \n` Fix `$contents` issues together --- 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 1034b49a5..8bf21f8e8 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -105,10 +105,10 @@ function __fish_print_hostnames -d "Print a list of known hostnames" if test -r $file # Don't read from $file twice. We could use `while read` instead, but that is extremely # slow. - read -z -l contents <$file + read -alz -d \n contents <$file # Print hosts from system wide ssh configuration file - string replace -rfi '^\s*Host\s+(\S.*?)\s*$' '$1' -- $contents | string split ' ' | string match -v '*\**' + string replace -rfi '^\s*Host\s+(\S.*?)\s*$' '$1' -- $contents | string match -v '*\**' # Also extract known_host paths. set known_hosts $known_hosts (string replace -rfi '.*KnownHostsFile\s*' '' -- $contents) end