@@ -2449,9 +2449,9 @@ _known_hosts_real()
24492449
24502450 # If we have known_hosts files to use
24512451 if (( ${# kh[@]} + ${# khd[@]} > 0 )) ; then
2452- if (( ${# kh[@]} > 0 )) ; then
2453- COMPREPLY+=() # make sure it exists
2452+ local -a tmp=()
24542453
2454+ if (( ${# kh[@]} > 0 )) ; then
24552455 # https://man.openbsd.org/sshd.8#SSH_KNOWN_HOSTS_FILE_FORMAT
24562456 for i in " ${kh[@]} " ; do
24572457 while read -ra tmpkh; do
@@ -2472,35 +2472,29 @@ _known_hosts_real()
24722472 # Remove trailing ] + optional :port
24732473 host=${host% ]?(: +([0-9]))}
24742474 # Add host to candidates
2475- [[ $host ]] &&
2476- COMPREPLY+=(" $host " )
2475+ [[ $host ]] && tmp+=(" $host " )
24772476 done
24782477 fi
24792478 done < " $i "
24802479 done
2481- (( ${# COMPREPLY[@]} )) &&
2482- _comp_compgen -- -W ' "${COMPREPLY[@]}"'
24832480 fi
24842481 if (( ${# khd[@]} > 0 )) ; then
24852482 # Needs to look for files called
24862483 # .../.ssh2/key_22_<hostname>.pub
24872484 # dont fork any processes, because in a cluster environment,
24882485 # there can be hundreds of hostkeys
24892486 for i in " ${khd[@]} " ; do
2490- if [[ $i == * key_22_$cur * .pub && -r $i ]]; then
2487+ if [[ $i == * key_22_* .pub && -r $i ]]; then
24912488 host=${i/#* key_22_/ }
24922489 host=${host/% .pub/ }
2493- [[ $host ]] && COMPREPLY +=(" $host " )
2490+ [[ $host ]] && tmp +=(" $host " )
24942491 fi
24952492 done
24962493 fi
24972494
24982495 # apply suffix and prefix
2499- if (( ${# COMPREPLY[@]} )) ; then
2500- for i in ${! COMPREPLY[*]} ; do
2501- COMPREPLY[i]=$prefix ${COMPREPLY[i]} $suffix
2502- done
2503- fi
2496+ (( ${# tmp[@]} )) &&
2497+ _comp_compgen -- -W ' "${tmp[@]}"' -P " $prefix " -S " $suffix "
25042498 fi
25052499
25062500 # append any available aliases from ssh config files
0 commit comments