summaryrefslogtreecommitdiff
path: root/test/lib/completions/ssh.exp
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/completions/ssh.exp')
-rw-r--r--test/lib/completions/ssh.exp18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/lib/completions/ssh.exp b/test/lib/completions/ssh.exp
index 3ef0bb69..c082558e 100644
--- a/test/lib/completions/ssh.exp
+++ b/test/lib/completions/ssh.exp
@@ -60,7 +60,23 @@ sync_after_int
set test "First argument should complete partial hostname"
-assert_complete_partial [get_known_hosts] ssh "l" $test -ltrim-colon-completions
+# Build string list of hostnames, starting with the character of the first
+# host, unless host starts with a COMP_WORDBREAKS character, e.g. a colon (:).
+# Hosts starting with a COMP_WORDBREAKS character are left out because these
+# are exceptional cases, requiring specific tests.
+set hosts {}
+set char ""
+foreach h [get_known_hosts] {
+ set first [string range $h 0 0]
+ if {$char == "" && [string first $first $::COMP_WORDBREAKS] == -1} {set char $first}
+ if {$char != ""} {
+ # Only append unique hostnames starting with $char
+ if {$first == $char && [lsearch -exact $hosts "$h"] == -1} {
+ lappend hosts "$h"
+ }
+ }
+}
+assert_complete $hosts "ssh $char" $test -ltrim-colon-completions -expect-cmd-minus "$char"
sync_after_int