From defdc92b5734c76010479ad2025065a66e1ac5aa Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Wed, 26 Jul 2017 20:41:00 -0700 Subject: [PATCH] fix ssh config `Include` file handling Fixes #4253 --- share/functions/__fish_print_hostnames.fish | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/share/functions/__fish_print_hostnames.fish b/share/functions/__fish_print_hostnames.fish index 8844154d2..0bf89e334 100644 --- a/share/functions/__fish_print_hostnames.fish +++ b/share/functions/__fish_print_hostnames.fish @@ -44,14 +44,14 @@ function __fish_print_hostnames -d "Print a list of known hostnames" function _ssh_include --argument-names ssh_config # Relative paths in Include directive use /etc/ssh or ~/.ssh depending on # system or user level config. -F will not override this behaviour - if test $ssh_config = '/etc/ssh/ssh_config' + set -l relative_path $HOME/.ssh + if string match '/etc/ssh/*' -- $ssh_config set relative_path '/etc/ssh' - else - set relative_path $HOME/.ssh end function _recursive --no-scope-shadowing - set paths + set -l orig_dir $PWD + set -l paths for config in $argv set paths $paths (cat $config ^/dev/null \ # Keep only Include lines @@ -62,10 +62,11 @@ function __fish_print_hostnames -d "Print a list of known hostnames" | string trim | string replace -r -a '\s+' ' ') end + cd $relative_path set -l new_paths for path in $paths set -l expanded_path - eval set expanded_path (echo $path) + eval "set expanded_path (printf \"%s\n\" $path)" for path in $expanded_path # Resolve "relative" paths in accordance to ssh path resolution if string match -qv '/*' $path @@ -75,9 +76,9 @@ function __fish_print_hostnames -d "Print a list of known hostnames" set new_paths $new_paths $path end end + cd $orig_dir if test -n "$new_paths" - _recursive $new_paths end end