pcmpl-ssh-known-hosts tiny change
authorMike Lamb <mrlamb@gmail.com>
Fri, 27 Jan 2012 21:14:16 +0000 (13:14 -0800)
committerGlenn Morris <rgm@gnu.org>
Fri, 27 Jan 2012 21:14:16 +0000 (13:14 -0800)
* lisp/pcmpl-unix.el (pcmpl-ssh-known-hosts): Handle [host]:port syntax.

Fixes: debbugs:10533

lisp/ChangeLog
lisp/pcmpl-unix.el

index 571a5e2..a907bd4 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-27  Mike Lamb  <mrlamb@gmail.com>  (tiny change)
+
+       * pcmpl-unix.el (pcmpl-ssh-known-hosts):
+       Handle [host]:port syntax.  (Bug#10533)
+
 2012-01-27  Alex Harsanyi  <harsanyi@mac.com>
 
        * xml.el (xml-parse-tag): Fix parsing of comments (Bug#10405).
index 2dc25d9..3af22c8 100644 (file)
@@ -152,13 +152,15 @@ documentation), this function returns nil."
              (file-readable-p pcmpl-ssh-known-hosts-file))
     (with-temp-buffer
       (insert-file-contents-literally pcmpl-ssh-known-hosts-file)
-      (let (ssh-hosts-list)
-        (while (re-search-forward "^ *\\([-.[:alnum:]]+\\)[, ]" nil t)
-          (add-to-list 'ssh-hosts-list (match-string 1))
+      (let ((host-re "\\(?:\\([-.[:alnum:]]+\\)\\|\\[\\([-.[:alnum:]]+\\)\\]:[0-9]+\\)[, ]")
+            ssh-hosts-list)
+        (while (re-search-forward (concat "^ *" host-re) nil t)
+          (add-to-list 'ssh-hosts-list (concat (match-string 1)
+                                               (match-string 2)))
           (while (and (looking-back ",")
-                      (re-search-forward "\\([-.[:alnum:]]+\\)[, ]"
-                                         (line-end-position) t))
-            (add-to-list 'ssh-hosts-list (match-string 1))))
+                      (re-search-forward host-re (line-end-position) t))
+            (add-to-list 'ssh-hosts-list (concat (match-string 1)
+                                                 (match-string 2)))))
         ssh-hosts-list))))
 
 (defun pcmpl-ssh-config-hosts ()