]> git.eshelyaron.com Git - emacs.git/commitdiff
Tramp code cleanup
authorMichael Albinus <michael.albinus@gmx.de>
Thu, 16 Sep 2021 14:50:24 +0000 (16:50 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Thu, 16 Sep 2021 14:50:24 +0000 (16:50 +0200)
* lisp/net/tramp-sh.el (tramp-methods) <telnet, nc>:
Reintroduce "%n" marker.
(tramp-maybe-open-connection): Handle it.

* lisp/net/tramp.el (tramp-prefix-regexp):
* lisp/net/tramp-smb.el (tramp-smb-options): Fix docstring.

* lisp/net/tramp*.el: Fix typos.  Remove trailing space from
`yes-or-no-p' and `y-or-n-p' prompts.

* test/lisp/net/tramp-tests.el (tramp--test-telnet-p): New defun.
(tramp-test29-start-file-process, tramp-test30-make-process)
(tramp-test35-remote-path, tramp-test44-asynchronous-requests):
Adapt tests.

13 files changed:
lisp/net/tramp-adb.el
lisp/net/tramp-archive.el
lisp/net/tramp-cmds.el
lisp/net/tramp-crypt.el
lisp/net/tramp-ftp.el
lisp/net/tramp-gvfs.el
lisp/net/tramp-sh.el
lisp/net/tramp-smb.el
lisp/net/tramp-sshfs.el
lisp/net/tramp-sudoedit.el
lisp/net/tramp.el
lisp/net/trampver.el
test/lisp/net/tramp-tests.el

index a35ac37a207d0a829f9311aff213e38b9aacb7f1..46064a857453e249135ec5c164a007abfe551388 100644 (file)
@@ -361,7 +361,7 @@ arguments to pass to the OPERATION."
     (tramp-message vec 5 "Finding a suitable `ls' command")
     (cond
      ;; Support Android derived systems where "ls" command is provided
-     ;; by GNU Coreutils. Force "ls" to print one column and set
+     ;; by GNU Coreutils.  Force "ls" to print one column and set
      ;; time-style to imitate other "ls" flavors.
      ((tramp-adb-send-command-and-check
        vec (concat "ls --time-style=long-iso "
@@ -548,7 +548,7 @@ But handle the case, if the \"test\" command is not available."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
index 67798e892ab3c774e009f4692a76e4d3bbfeacbc..5e2e1f06023bb1f779bcd2a07c3086d0f8370218 100644 (file)
@@ -190,7 +190,7 @@ It must be supported by libarchive(3).")
 
 ;; In older Emacsen (prior 27.1), `tramp-archive-autoload-file-name-regexp'
 ;; is not autoloaded.  So we cannot expect it to be known in
-;; tramp-loaddefs.el. But it exists, when tramp-archive.el is loaded.
+;; tramp-loaddefs.el.  But it exists, when tramp-archive.el is loaded.
 ;;;###tramp-autoload
 (defconst tramp-archive-file-name-regexp
   (ignore-errors (tramp-archive-autoload-file-name-regexp))
index 6278fd302af042473e4a6418a08da9639a223835..bfd928731a34291890c750a83674b53bafbaa082 100644 (file)
@@ -312,7 +312,7 @@ The remote connection identified by SOURCE is flushed by
      (if (null connections)
         (tramp-user-error nil "There are no remote connections.")
        (setq source
-            ;; Likely, the source remote connection is broken. So we
+            ;; Likely, the source remote connection is broken.  So we
             ;; shall avoid any action on it.
             (let (non-essential)
               (completing-read-default
@@ -717,7 +717,7 @@ the debug buffer(s).")
        (setq buffer-read-only t)
        (goto-char (point-min))
 
-       (when (y-or-n-p "Do you want to append the buffer(s)? ")
+       (when (y-or-n-p "Do you want to append the buffer(s)?")
          ;; OK, let's send.  First we delete the buffer list.
          (kill-buffer nil)
          (switch-to-buffer curbuf)
index fdb2907ec3243bdc8983830a7c6673c95fef2d40..5f86767ef94f3548cef5e266badea03bdcbb6710 100644 (file)
@@ -517,7 +517,7 @@ kept in their encrypted form."
              tramp-crypt-encfs-config
              (directory-files name nil directory-files-no-dot-files-regexp))
             (yes-or-no-p
-             "There exist encrypted files, do you want to continue? "))
+             "There exist encrypted files, do you want to continue?"))
     (setq tramp-crypt-directories (delete name tramp-crypt-directories))
     (tramp-register-file-name-handlers)))
 
index fa2df89e495bac12f5b7dc1b389f33f5f48417f2..11ccdc8a4c90d093dafb5ecad7488def22ed3cf7 100644 (file)
@@ -120,15 +120,15 @@ pass to the OPERATION."
                 (nth 2 tramp-file-name-structure)
                 (nth 4 tramp-file-name-structure)))
          ;; ange-ftp uses `ange-ftp-ftp-name-arg' and `ange-ftp-ftp-name-res'
-         ;; for optimization in `ange-ftp-ftp-name'. If Tramp wasn't active,
+         ;; for optimization in `ange-ftp-ftp-name'.  If Tramp wasn't active,
          ;; there could be incorrect values from previous calls in case the
-         ;; "ftp" method is used in the Tramp file name. So we unset
+         ;; "ftp" method is used in the Tramp file name.  So we unset
          ;; those values.
          (ange-ftp-ftp-name-arg "")
          (ange-ftp-ftp-name-res nil))
       (cond
        ;; If argument is a symlink, `file-directory-p' and
-       ;; `file-exists-p' call the traversed file recursively. So we
+       ;; `file-exists-p' call the traversed file recursively.  So we
        ;; cannot disable the file-name-handler this case.  We set the
        ;; connection property "started" in order to put the remote
        ;; location into the cache, which is helpful for further
index 25deead81333a83f917cdbbc3e80918be1f37508..5f0e7bcd98c786f739a24dc0ae53225397940b28 100644 (file)
@@ -1815,10 +1815,8 @@ a downcased host name only."
                             (message "%s" message)
                           (pop-to-buffer (current-buffer)))
                         (if (yes-or-no-p
-                             (concat
-                              (buffer-substring
-                               (line-beginning-position) (point))
-                              " "))
+                             (buffer-substring
+                              (line-beginning-position) (point)))
                             0 1)))))
 
                ;; When QUIT is raised, we shall return this
@@ -1840,7 +1838,7 @@ a downcased host name only."
   (ignore-errors
     (let ((signal-name (dbus-event-member-name last-input-event))
          (elt mount-info))
-      ;; Jump over the first elements of the mount info. Since there
+      ;; Jump over the first elements of the mount info.  Since there
       ;; were changes in the entries, we cannot access dedicated
       ;; elements.
       (while (stringp (car elt)) (setq elt (cdr elt)))
@@ -1936,7 +1934,7 @@ a downcased host name only."
              :session tramp-gvfs-service-daemon tramp-gvfs-path-mounttracker
              tramp-gvfs-interface-mounttracker tramp-gvfs-listmounts))
          nil)
-       ;; Jump over the first elements of the mount info. Since there
+       ;; Jump over the first elements of the mount info.  Since there
        ;; were changes in the entries, we cannot access dedicated
        ;; elements.
        (while (stringp (car elt)) (setq elt (cdr elt)))
index d0a340a5df7aadcd974b05ebd1174310e60ed19e..22d4712985c667f25c364e951255e11cd11c223c 100644 (file)
@@ -244,14 +244,14 @@ The string is used in `tramp-methods'.")
  (add-to-list 'tramp-methods
               `("telnet"
                 (tramp-login-program        "telnet")
-                (tramp-login-args           (("%h") ("%p")))
+                (tramp-login-args           (("%h") ("%p") ("%n")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))))
  (add-to-list 'tramp-methods
               `("nc"
                 (tramp-login-program        "telnet")
-                (tramp-login-args           (("%h") ("%p")))
+                (tramp-login-args           (("%h") ("%p") ("%n")))
                 (tramp-remote-shell         ,tramp-default-remote-shell)
                 (tramp-remote-shell-login   ("-l"))
                 (tramp-remote-shell-args    ("-c"))
@@ -1064,7 +1064,7 @@ component is used as the target of the symlink."
                         (not
                          (yes-or-no-p
                           (format
-                           "File %s already exists; make it a link anyway? "
+                           "File %s already exists; make it a link anyway?"
                            localname)))))
                (tramp-error v 'file-already-exists localname)
              (delete-file linkname)))
@@ -1073,7 +1073,7 @@ component is used as the target of the symlink."
 
          ;; Right, they are on the same host, regardless of user,
          ;; method, etc.  We now make the link on the remote
-         ;; machine. This will occur as the user that TARGET belongs to.
+         ;; machine.  This will occur as the user that TARGET belongs to.
          (and (tramp-send-command-and-check
                v (format "cd %s" (tramp-shell-quote-argument cwd)))
                (tramp-send-command-and-check
@@ -1825,7 +1825,7 @@ ID-FORMAT valid values are `string' and `integer'."
                  (and (numberp ok-if-already-exists)
                       (not (yes-or-no-p
                             (format
-                             "File %s already exists; make it a link anyway? "
+                             "File %s already exists; make it a link anyway?"
                              v2-localname)))))
              (tramp-error v2 'file-already-exists newname)
            (delete-file newname)))
@@ -2231,7 +2231,7 @@ the uid and gid from FILENAME."
                ;; Save exit.
                (ignore-errors (delete-file tmpfile)))))))))
 
-      ;; Set the time and mode. Mask possible errors.
+      ;; Set the time and mode.  Mask possible errors.
       (ignore-errors
          (when keep-date
            (tramp-compat-set-file-times
@@ -2748,7 +2748,7 @@ the result will be a local, non-Tramp, file name."
 
 ;;; Remote commands:
 
-;; We use BUFFER also as connection buffer during setup. Because of
+;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-sh-handle-make-process (&rest args)
@@ -3269,7 +3269,7 @@ implementation will be used."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -4000,7 +4000,7 @@ Returns the absolute file name of PROGNAME, if found, and nil otherwise.
 This function expects to be in the right *tramp* buffer."
   (with-current-buffer (tramp-get-connection-buffer vec)
     (let (result)
-      ;; Check whether the executable is in $PATH. "which(1)" does not
+      ;; Check whether the executable is in $PATH.  "which(1)" does not
       ;; report always a correct error code; therefore we check the
       ;; number of words it returns.  "SunOS 5.10" (and maybe "SunOS
       ;; 5.11") have problems with this command, we disable the call
@@ -4904,6 +4904,8 @@ connection if a previous connection has died for some reason."
                 (tramp-error vec 'file-error "`tramp-encoding-shell' not set"))
              (let* ((current-host tramp-system-name)
                     (target-alist (tramp-compute-multi-hops vec))
+                    ;; Needed for `tramp-get-remote-null-device'.
+                    (previous-hop nil)
                     ;; We will apply `tramp-ssh-controlmaster-options'
                     ;; only for the first hop.
                     (options (tramp-ssh-controlmaster-options vec))
@@ -5016,6 +5018,8 @@ connection if a previous connection has died for some reason."
                        hop 'tramp-login-args
                        ?h (or l-host "") ?u (or l-user "") ?p (or l-port "")
                        ?c (format-spec options (format-spec-make ?t tmpfile))
+                       ?n (concat
+                           "2>" (tramp-get-remote-null-device previous-hop))
                        ?l (concat remote-shell " " extra-args " -i"))
                       ;; A restricted shell does not allow "exec".
                       (when r-shell '("&&" "exit" "||" "exit")))
@@ -5031,10 +5035,12 @@ connection if a previous connection has died for some reason."
                     tramp-actions-before-shell
                     (or connection-timeout tramp-connection-timeout))
                    (tramp-message
-                    vec 3 "Found remote shell prompt on `%s'" l-host))
-                 ;; Next hop.
-                 (setq options ""
-                       target-alist (cdr target-alist)))
+                    vec 3 "Found remote shell prompt on `%s'" l-host)
+
+                   ;; Next hop.
+                   (setq options ""
+                         target-alist (cdr target-alist)
+                         previous-hop hop)))
 
                ;; Activate session timeout.
                (when (tramp-get-connection-property p "session-timeout" nil)
index 5cfe874f00ae70dd592291760e9e99391e01d68f..fa5bce74bb11dbb6e2c6b0b13e0e6df3b63e3148 100644 (file)
@@ -48,7 +48,7 @@
                   ;; Another guess.  We might implement a better check later on.
                   (tramp-case-insensitive t)))))
 
-;; Add a default for `tramp-default-user-alist'. Rule: For the SMB method,
+;; Add a default for `tramp-default-user-alist'.  Rule: For the SMB method,
 ;; the anonymous user is chosen.
 ;;;###tramp-autoload
 (tramp--with-startup
@@ -83,7 +83,7 @@ call, letting the SMB client use the default one."
 They are added to the `tramp-smb-program' call via \"--option '...'\".
 
 For example, if the deprecated SMB1 protocol shall be used, add to
-this variable (\"client min protocol=NT1\") ."
+this variable \"client min protocol=NT1\"."
   :group 'tramp
   :type '(repeat string)
   :version "28.1")
@@ -376,7 +376,7 @@ arguments to pass to the OPERATION."
                (and (numberp ok-if-already-exists)
                     (not (yes-or-no-p
                           (format
-                           "File %s already exists; make it a link anyway? "
+                           "File %s already exists; make it a link anyway?"
                            v2-localname)))))
            (tramp-error v2 'file-already-exists newname)
          (delete-file newname)))
@@ -1247,7 +1247,7 @@ component is used as the target of the symlink."
                  (and (numberp ok-if-already-exists)
                       (not (yes-or-no-p
                             (format
-                             "File %s already exists; make it a link anyway? "
+                             "File %s already exists; make it a link anyway?"
                              localname)))))
              (tramp-error v 'file-already-exists localname)
            (delete-file linkname)))
@@ -1526,7 +1526,7 @@ component is used as the target of the symlink."
          (tramp-error
           v 'file-error "Error while changing file's mode %s" filename))))))
 
-;; We use BUFFER also as connection buffer during setup. Because of
+;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-smb-handle-start-file-process (name buffer program &rest args)
@@ -1603,7 +1603,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -1703,7 +1703,7 @@ If VEC has no cifs capabilities, exchange \"/\" by \"\\\\\"."
 
       localname)))
 
-;; Share names of a host are cached. It is very unlikely that the
+;; Share names of a host are cached.  It is very unlikely that the
 ;; shares do change during connection.
 (defun tramp-smb-get-file-entries (directory)
   "Read entries which match DIRECTORY.
@@ -2200,5 +2200,7 @@ Removes smb prompt.  Returns nil if an error message has appeared."
 ;;
 ;; * Try to remove the inclusion of dummy "" directory.  Seems to be at
 ;;   several places, especially in `tramp-smb-handle-insert-directory'.
+;;
+;; * Keep a separate connection process per share.
 
 ;;; tramp-smb.el ends here
index c5b84a6e4e46f83b642a41cc4620aaa5407c5bc1..0019ac014f88b456dccd2ddfac900c10b4b1faa5 100644 (file)
@@ -292,7 +292,7 @@ arguments to pass to the OPERATION."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t)))
index 051d145c2a25039152e1b042ba214def018b665d..516d46da37d519912ad7e20e75ce0fceaff2d15f 100644 (file)
@@ -190,7 +190,7 @@ arguments to pass to the OPERATION."
                  (and (numberp ok-if-already-exists)
                       (not (yes-or-no-p
                             (format
-                             "File %s already exists; make it a link anyway? "
+                             "File %s already exists; make it a link anyway?"
                              v2-localname)))))
              (tramp-error v2 'file-already-exists newname)
            (delete-file newname)))
@@ -632,7 +632,7 @@ component is used as the target of the symlink."
                       (not
                        (yes-or-no-p
                         (format
-                         "File %s already exists; make it a link anyway? "
+                         "File %s already exists; make it a link anyway?"
                          localname)))))
              (tramp-error v 'file-already-exists localname)
            (delete-file linkname)))
index 0182248dfadda97a79e82f46f4e7c7385c32bc48..6ed67034f4e076d65a001a13e8efefb80db7b7a5 100644 (file)
@@ -861,7 +861,7 @@ Used in `tramp-make-tramp-file-name'.")
 
 (defvar tramp-prefix-regexp nil ;Initialized when defining `tramp-syntax'!
   "Regexp matching the very beginning of Tramp file names.
-Should always start with \"^\". Derived from `tramp-prefix-format'.")
+Should always start with \"^\".  Derived from `tramp-prefix-format'.")
 
 (defconst tramp-method-regexp-alist
   '((default    . "[[:alnum:]-]+")
@@ -2379,7 +2379,7 @@ For definition of that list see `tramp-set-completion-function'."
 
 ;; Inodes don't exist for some file systems.  Therefore we must
 ;; generate virtual ones.  Used in `find-buffer-visiting'.  The method
-;; applied might be not so efficient (Ange-FTP uses hashes). But
+;; applied might be not so efficient (Ange-FTP uses hashes).  But
 ;; performance isn't the major issue given that file transfer will
 ;; take time.
 (defvar tramp-inodes 0
@@ -2908,7 +2908,7 @@ not in completion mode."
 ;; I misuse a little bit the `tramp-file-name' structure in order to
 ;; handle completion possibilities for partial methods / user names /
 ;; host names.  Return value is a list of `tramp-file-name' structures
-;; according to possible completions. If "localname" is non-nil it
+;; according to possible completions.  If "localname" is non-nil it
 ;; means there shouldn't be a completion anymore.
 
 ;; Expected results:
@@ -3288,7 +3288,7 @@ User is always nil."
              (and (numberp ok-if-already-exists)
                   (not (yes-or-no-p
                         (format
-                         "File %s already exists; make it a link anyway? "
+                         "File %s already exists; make it a link anyway?"
                          localname)))))
          (tramp-error v 'file-already-exists newname)
        (delete-file newname)))
@@ -3463,7 +3463,7 @@ User is always nil."
     (or ;; Maybe there is a default value.
      (tramp-get-method-parameter v 'tramp-case-insensitive)
 
-     ;; There isn't. So we must check, in case there's a connection already.
+     ;; There isn't.  So we must check, in case there's a connection already.
      (and (file-remote-p filename nil 'connected)
           (with-tramp-connection-property v "case-insensitive"
            (ignore-errors
@@ -3694,7 +3694,7 @@ User is always nil."
                          (yes-or-no-p
                           (concat
                            "Backup file on local temporary directory, "
-                           "do you want to continue? ")))))
+                           "do you want to continue?")))))
          (tramp-error v 'file-error "Unsafe backup file name"))))))
 
 (defun tramp-handle-insert-directory
@@ -3915,7 +3915,7 @@ Return nil when there is no lockfile."
                            (yes-or-no-p
                             (concat
                              "Lock file on local temporary directory, "
-                             "do you want to continue? ")))))
+                             "do you want to continue?")))))
            (tramp-error v 'file-error "Unsafe lock file name")))
 
        ;; Do the lock.
@@ -4274,13 +4274,13 @@ support symbolic links."
        ((eq async-shell-command-buffer 'confirm-kill-process)
        ;; If will kill a process, query first.
        (if (yes-or-no-p
-            "A command is running in the default buffer.  Kill it? ")
+            "A command is running in the default buffer.  Kill it?")
            (kill-process p)
          (tramp-user-error p "Shell command in progress")))
        ((eq async-shell-command-buffer 'confirm-new-buffer)
        ;; If will create a new buffer, query first.
        (if (yes-or-no-p
-            "A command is running in the default buffer.  Use a new buffer? ")
+            "A command is running in the default buffer.  Use a new buffer?")
             (setq output-buffer (generate-new-buffer bname))
          (tramp-user-error p "Shell command in progress")))
        ((eq async-shell-command-buffer 'new-buffer)
@@ -4289,7 +4289,7 @@ support symbolic links."
        ((eq async-shell-command-buffer 'confirm-rename-buffer)
        ;; If will rename the buffer, query first.
        (if (yes-or-no-p
-            "A command is running in the default buffer.  Rename it? ")
+            "A command is running in the default buffer.  Rename it?")
            (progn
              (with-current-buffer output-buffer
                (rename-uniquely))
@@ -4492,7 +4492,7 @@ of."
               (or (eq mustbenew 'excl)
                   (not
                    (y-or-n-p
-                    (format "File %s exists; overwrite anyway? " filename)))))
+                    (format "File %s exists; overwrite anyway?" filename)))))
       (tramp-error v 'file-already-exists filename))
 
     (let ((file-locked (eq (file-locked-p lockname) t))
@@ -5468,7 +5468,7 @@ this file, if that variable is non-nil."
                          (yes-or-no-p
                           (concat
                            "Autosave file on local temporary directory, "
-                           "do you want to continue? ")))))
+                           "do you want to continue?")))))
          (tramp-error v 'file-error "Unsafe autosave file name"))))))
 
 (defun tramp-subst-strs-in-string (alist string)
index 8ad641ee45b83ed134c0a9604018c2c7c26f28ab..8baf0780c28fb8835fa78955e0a523606075a084 100644 (file)
@@ -29,7 +29,7 @@
 
 ;;; Commentary:
 
-;; Convenience functions around the Tramp version. Partly generated
+;; Convenience functions around the Tramp version.  Partly generated
 ;; during Tramp configuration.
 
 ;;; Code:
index af4f45d6913b76998baa65c2e683a4c5983fe429..9f0264abc1bf47b80913e496bc1a129c1a324632 100644 (file)
@@ -2083,7 +2083,7 @@ Also see `ignore'."
       "/method:host:/:/path//foo"))
 
     ;; Forwhatever reasons, the following tests let Emacs crash for
-    ;; Emacs 25, occasionally. No idea what's up.
+    ;; Emacs 25, occasionally.  No idea what's up.
     (when (tramp--test-emacs26-p)
       (should
        (string-equal
@@ -4464,7 +4464,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
              (should (string-equal (format "%s\n" fnnd) (buffer-string)))
              (should-not (get-buffer-window (current-buffer) t))
 
-             ;; Second run. The output must be appended.
+             ;; Second run.  The output must be appended.
              (goto-char (point-max))
              (should (zerop (process-file "ls" nil t t fnnd)))
              ;; `ls' could produce colorized output.
@@ -4588,8 +4588,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
                (should
                 (string-match-p
                  (if (memq process-connection-type '(nil pipe))
-                     "66\n6F\n6F\n0D\n0A\n"
-                   "66\n6F\n6F\n0A\n0A\n")
+                     ;; `telnet' converts \r to <CR><NUL> if `crlf'
+                     ;; flag is FALSE.  See telnet(1) man page.
+                     "66\n6F\n6F\n0D\\(\n00\\)?\n0A\n"
+                   "66\n6F\n6F\n0A\\(\n00\\)?\n0A\n")
                  (buffer-string))))
 
            ;; Cleanup.
@@ -4754,8 +4756,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
        ;; Cleanup.
        (ignore-errors (delete-process proc)))
 
-      ;; Process with stderr buffer.
-      (unless (tramp-direct-async-process-p)
+      ;; Process with stderr buffer.  `telnet' does not cooperate with
+      ;; three processes.
+      (unless (or (tramp--test-telnet-p) (tramp-direct-async-process-p))
        (let ((stderr (generate-new-buffer "*stderr*")))
          (unwind-protect
              (with-temp-buffer
@@ -4851,8 +4854,10 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'."
                   (string-match-p
                    (if (memq (or connection-type process-connection-type)
                              '(nil pipe))
-                       "66\n6F\n6F\n0D\n0A\n"
-                     "66\n6F\n6F\n0A\n0A\n")
+                       ;; `telnet' converts \r to <CR><NUL> if `crlf'
+                       ;; flag is FALSE.  See telnet(1) man page.
+                       "66\n6F\n6F\n0D\\(\n00\\)?\n0A\n"
+                     "66\n6F\n6F\n0A\\(\n00\\)?\n0A\n")
                    (buffer-string))))
 
              ;; Cleanup.
@@ -5498,9 +5503,9 @@ Use direct async.")
           ;; Ignore trailing newline.
          (setq path (substring (shell-command-to-string "echo $PATH") nil -1))
          ;; The shell doesn't handle such long strings.
-         (unless (<= (length path)
-                     (tramp-get-connection-property
-                      tramp-test-vec "pipe-buf" 4096))
+         (when (<= (length path)
+                   (tramp-get-connection-property
+                    tramp-test-vec "pipe-buf" 4096))
            ;; The last element of `exec-path' is `exec-directory'.
             (should
             (string-equal
@@ -6154,6 +6159,12 @@ This requires restrictions of file name syntax."
   "Check, whether the sudoedit method is used."
   (tramp-sudoedit-file-name-p tramp-test-temporary-file-directory))
 
+(defun tramp--test-telnet-p ()
+  "Check, whether the telnet method is used.
+This does not support special file names."
+  (string-equal
+   "telnet" (file-remote-p tramp-test-temporary-file-directory 'method)))
+
 (defun tramp--test-windows-nt-p ()
   "Check, whether the locale host runs MS Windows."
   (eq system-type 'windows-nt))
@@ -6712,6 +6723,7 @@ process sentinels.  They shall not disturb each other."
                   (tramp--test-sh-p)))
   (skip-unless (not (tramp--test-crypt-p)))
   (skip-unless (not (tramp--test-docker-p)))
+  (skip-unless (not (tramp--test-telnet-p)))
   (skip-unless (not (tramp--test-windows-nt-p)))
 
   (with-timeout