emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master c273e26af5: Some tramp-docker.el adaptions


From: Michael Albinus
Subject: master c273e26af5: Some tramp-docker.el adaptions
Date: Tue, 27 Sep 2022 12:46:38 -0400 (EDT)

branch: master
commit c273e26af58aab340b470595874893b23dab208d
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Some tramp-docker.el adaptions
    
    * lisp/net/tramp-docker.el (tramp-docker--completion-function):
    Add ;;;###tramp-autoload cookie.  Make implementation more robust.
    (tramp-methods) Use `tramp-default-remote-shell'.
---
 lisp/net/tramp-docker.el | 31 +++++++++++++++++--------------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/lisp/net/tramp-docker.el b/lisp/net/tramp-docker.el
index 40257a4a12..918469908a 100644
--- a/lisp/net/tramp-docker.el
+++ b/lisp/net/tramp-docker.el
@@ -53,23 +53,26 @@
 (defconst tramp-docker-method "docker"
   "Tramp method name to use to connect to Docker containers.")
 
+;;;###tramp-autoload
 (defun tramp-docker--completion-function (&rest _args)
   "List Docker containers available for connection.
 
 This function is used by `tramp-set-completion-function', please
 see its function help for a description of the format."
-  (let* ((raw-list (shell-command-to-string
-                    (concat tramp-docker-program
-                            " ps --format '{{.ID}}\t{{.Names}}'")))
-         (lines (split-string raw-list "\n"))
-         (names (mapcar (lambda (line)
-                          (let ((words (split-string line "\t")))
-                            (or (nth 1 words) (nth 0 words))))
-                        lines))
-         (machines (seq-take-while (lambda (name) name) names)))
-    (mapcar (lambda (m) (list nil m)) machines)))
-
-;; todo: check tramp-async-args and tramp-direct-async
+  (when-let ((raw-list (shell-command-to-string
+                       (concat tramp-docker-program
+                               " ps --format '{{.ID}}\t{{.Names}}'")))
+             (lines (split-string raw-list "\n" 'omit))
+             (names (mapcar
+                    (lambda (line)
+                       (when (string-match
+                             (rx bol (group (1+ nonl))
+                                 "\t" (? (group (1+ nonl))) eol)
+                             line)
+                        (or (match-string 2 line) (match-string 1 line))))
+                     lines)))
+    (mapcar (lambda (m) (list nil m)) (delq nil names))))
+
 ;;;###tramp-autoload
 (tramp--with-startup
  (push `(,tramp-docker-method
@@ -78,8 +81,8 @@ see its function help for a description of the format."
                             ("-it")
                             ("-u" "%u")
                             ("%h")
-                           ("/bin/sh")))
-         (tramp-remote-shell "/bin/sh")
+                           ("%l")))
+         (tramp-remote-shell ,tramp-default-remote-shell)
          (tramp-remote-shell-login ("-l"))
          (tramp-remote-shell-args ("-i" "-c")))
        tramp-methods)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]