summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_ssh28
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