(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 "
(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))
;; 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))
(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
(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)
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)))
(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
(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
(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)))
: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)))
(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"))
(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)))
;; 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
(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)))
;; 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
;;; 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)
(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))
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
(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))
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")))
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)
;; 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
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")
(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)))
(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)))
(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)
(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))
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.
;;
;; * 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
(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)))
(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)))
(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)))
(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:]-]+")
;; 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
;; 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:
(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)))
(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
(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
(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.
((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)
((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))
(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))
(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)
;;; Commentary:
-;; Convenience functions around the Tramp version. Partly generated
+;; Convenience functions around the Tramp version. Partly generated
;; during Tramp configuration.
;;; Code:
"/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
(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.
(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.
;; 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
(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.
;; 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
"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))
(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