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
This commit is contained in:
Akatsuki 2019-10-27 00:17:52 +08:00 committed by Fabian Homborg
parent 5b2250883a
commit b89a6451a3

View file

@ -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