diff options
Diffstat (limited to 'Completion/Unix/Type/_ssh_hosts')
-rw-r--r-- | Completion/Unix/Type/_ssh_hosts | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Completion/Unix/Type/_ssh_hosts b/Completion/Unix/Type/_ssh_hosts index bd5366425..b50e1c16a 100644 --- a/Completion/Unix/Type/_ssh_hosts +++ b/Completion/Unix/Type/_ssh_hosts @@ -20,10 +20,11 @@ if [[ -r $config ]]; then local key line host local -a lines=("${(@f)$(<"$config")}") 2>/dev/null local -a match_args - while (($#lines)); do - IFS=$'=\t ' read -r key line <<<"${lines[1]}" + local idx=1 + while (( idx <= $#lines )); do + IFS=$'=\t ' read -r key line <<<"${lines[idx]}" if [[ "$key" == ((#i)match) ]]; then - match_args=(${(z)line}) + match_args=( ${(Z.C.)line} ) while [[ $#match_args -ge 2 ]]; do if [[ "${match_args[1]}" == (#i)(canonical|final|(|original)host) ]]; then key="Host" @@ -35,15 +36,12 @@ if [[ -r $config ]]; then fi case "$key" in ((#i)include) - lines[1]=("${(@f)$(cd $HOME/.ssh; cat ${(z)~line})}") 2>/dev/null;; + lines[idx]=( "${(@f)$(cd $HOME/.ssh; cat ${(Z.C.)~line} 2>/dev/null)}" ) ;; ((#i)host(|name)) - for host in ${(z)line}; do - case $host in - (*[*?]*) ;; - (*) config_hosts+=("$host") ;; - esac + for host in ${(Z.C.)line}; do + [[ $host != *[*?%]* ]] && config_hosts+=( $host ) done ;& - (*) shift lines;; + (*) (( ++idx ));; esac done if (( ${#config_hosts} )); then |