Skip to content

Commit 71bc832

Browse files
committed
fix(_known_hosts_real): exclude directories from the config files
1 parent 685b510 commit 71bc832

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

bash_completion

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,7 @@ _included_ssh_config_files()
19051905
_comp_expand_glob files '$i'
19061906
if ((${#files[@]})); then
19071907
for f in "${files[@]}"; do
1908-
if [[ -r $f ]]; then
1908+
if [[ -r $f && ! -d $f ]]; then
19091909
config+=("$f")
19101910
# The Included file is processed to look for Included files in itself
19111911
_included_ssh_config_files $f
@@ -1973,10 +1973,10 @@ _known_hosts_real()
19731973

19741974
# ssh config files
19751975
if [[ -v configfile ]]; then
1976-
[[ -r $configfile ]] && config+=("$configfile")
1976+
[[ -r $configfile && ! -d $configfile ]] && config+=("$configfile")
19771977
else
19781978
for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do
1979-
[[ -r $i ]] && config+=("$i")
1979+
[[ -r $i && ! -d $i ]] && config+=("$i")
19801980
done
19811981
fi
19821982

@@ -2023,7 +2023,7 @@ _known_hosts_real()
20232023
for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \
20242024
/etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \
20252025
~/.ssh/known_hosts2; do
2026-
[[ -r $i ]] && kh+=("$i")
2026+
[[ -r $i && ! -r $i ]] && kh+=("$i")
20272027
done
20282028
for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
20292029
[[ -d $i ]] && khd+=("$i"/*pub)

0 commit comments

Comments
 (0)