diff options
author | Barton E. Schaefer <schaefer@zsh.org> | 2017-05-28 11:27:55 -0700 |
---|---|---|
committer | Barton E. Schaefer <schaefer@zsh.org> | 2017-05-28 11:27:55 -0700 |
commit | 5ded0ad96740b62ea0214387ee260b515726a05e (patch) | |
tree | 920d086576f379b99e6038cf00d9e9aee1c2bbd4 | |
parent | 62c416915b1bee6d7ef9dc87f6009907748f2087 (diff) | |
download | zsh-5ded0ad96740b62ea0214387ee260b515726a05e.tar.gz zsh-5ded0ad96740b62ea0214387ee260b515726a05e.tar.xz zsh-5ded0ad96740b62ea0214387ee260b515726a05e.zip |
41159: handle "Include" and "HostName" lines in ~/.ssh/config
Added 2>/dev/null to conceal file access errors.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Completion/Unix/Command/_ssh | 28 |
2 files changed, 22 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog index 8ce4aecf3..68e36e718 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2017-05-28 Barton E. Schaefer <schaefer@zsh.org> + + * 41159 (tweaked): Completion/Unix/Command/_ssh: handle "Include" + and "HostName" lines in ~/.ssh/config + 2017-05-24 Peter Stephenson <p.stephenson@samsung.com> * Sebastian: 41146: Src/Modules/db_gdbm.c: be more careful about diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index 6763e24e7..28d2c38e7 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -680,17 +680,23 @@ _ssh_hosts () { config="$HOME/.ssh/config" fi if [[ -r $config ]]; then - local key hosts host - while IFS=$'=\t ' read -r key hosts; do - if [[ "$key" == (#i)host ]]; then - for host in ${(z)hosts}; do - case $host in - (*[*?]*) ;; - (*) config_hosts+=("$host") ;; - esac - done - fi - done < "$config" + local key line host + local -a lines=("${(@f)$(<"$config")}") 2>/dev/null + while (($#lines)); do + IFS=$'=\t ' read -r key line <<<"${lines[1]}" + case "$key" in + ((#i)include) + lines[1]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}") 2>/dev/null;; + ((#i)host(|name)) + for host in ${(z)line}; do + case $host in + (*[*?]*) ;; + (*) config_hosts+=("$host") ;; + esac + done ;& + (*) shift lines;; + esac + done if (( ${#config_hosts} )); then _wanted hosts expl 'remote host name' \ compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" $config_hosts |