Skip to content

Commit dbae115

Browse files
akinomyogascop
andcommitted
fix(_known_hosts_real): fix "nounset" error with empty known_hosts
When known_hosts files are found but do not contain any valid hosts, COMPREPLY is not updated in the loop, which causes the "nounset" error in the test `((${#COMPREPLY[@]}))` after the loop. Co-authored-by: Ville Skyttä <ville.skytta@iki.fi>
1 parent 177cba1 commit dbae115

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

bash_completion

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,8 @@ _known_hosts_real()
19741974
# If we have known_hosts files to use
19751975
if ((${#kh[@]} + ${#khd[@]} > 0)); then
19761976
if ((${#kh[@]} > 0)); then
1977+
COMPREPLY+=() # make sure it exists
1978+
19771979
# https://man.openbsd.org/sshd.8#SSH_KNOWN_HOSTS_FILE_FORMAT
19781980
for i in "${kh[@]}"; do
19791981
while read -ra tmpkh; do

0 commit comments

Comments
 (0)