From 30abcda54e1b0e15fc10b3db1c2b9f89ca521bfa Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 7 Feb 2020 11:56:13 +0100 Subject: [PATCH] Some Tramp fixes * lisp/net/tramp.el (tramp-connectable-p): * lisp/net/tramp-cache.el (tramp-list-connections): * lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Bind `tramp-verbose' to 0. * lisp/net/tramp-sh.el (tramp-remote-path, tramp-find-executable): Fix docstring. (tramp-open-shell): Read prompt when moving "~/.editrc". --- lisp/net/tramp-cache.el | 19 ++++++++++--------- lisp/net/tramp-gvfs.el | 3 ++- lisp/net/tramp-sh.el | 26 ++++++++++++++++++-------- lisp/net/tramp.el | 4 ++-- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index 1998042d699..94eeb83ba34 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -411,15 +411,16 @@ used to cache connection properties of the local machine." ;;;###tramp-autoload (defun tramp-list-connections () "Return all known `tramp-file-name' structs according to `tramp-cache'." - (let (result tramp-verbose) - (maphash - (lambda (key _value) - (when (and (tramp-file-name-p key) - (null (tramp-file-name-localname key)) - (tramp-connection-property-p key "process-buffer")) - (push key result))) - tramp-cache-data) - result)) + (let ((tramp-verbose 0) + result) + (maphash + (lambda (key _value) + (when (and (tramp-file-name-p key) + (null (tramp-file-name-localname key)) + (tramp-connection-property-p key "process-buffer")) + (push key result))) + tramp-cache-data) + result)) (defun tramp-dump-connection-properties () "Write persistent connection properties into file `tramp-persistency-file-name'." diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 6e116731b7a..0d800cb42b3 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -2466,7 +2466,8 @@ This uses \"avahi-browse\" in case D-Bus is not enabled in Avahi." (when tramp-gvfs-enabled ;; Suppress D-Bus error messages and Tramp traces. - (let (tramp-gvfs-dbus-event-vector tramp-verbose fun) + (let ((tramp-verbose 0) + tramp-gvfs-dbus-event-vector fun) ;; Add completion functions for services announced by DNS-SD. ;; See for valid service types. (zeroconf-init tramp-gvfs-zeroconf-domain) diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 2e8793056ab..5a3abc31ea6 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -491,8 +491,8 @@ The string is used in `tramp-methods'.") For every remote host, this variable will be set buffer local, keeping the list of existing directories on that host. -You can use `~' in this list, but when searching for a shell which groks -tilde expansion, all directory names starting with `~' will be ignored. +You can use \"~\" in this list, but when searching for a shell which groks +tilde expansion, all directory names starting with \"~\" will be ignored. `Default Directories' represent the list of directories given by the command \"getconf PATH\". It is recommended to use this @@ -3953,7 +3953,7 @@ hosts, or files, disagree." First arg VEC specifies the connection, PROGNAME is the program to search for, and DIRLIST gives the list of directories to search. If IGNORE-TILDE is non-nil, directory names starting -with `~' will be ignored. If IGNORE-PATH is non-nil, searches +with \"~\" will be ignored. If IGNORE-PATH is non-nil, searches only in DIRLIST. Returns the absolute file name of PROGNAME, if found, and nil otherwise. @@ -4103,18 +4103,26 @@ file exists and nonzero exit status otherwise." (with-tramp-progress-reporter vec 5 (format-message "Opening remote shell `%s'" shell) ;; Find arguments for this shell. - (let ((extra-args (tramp-get-sh-extra-args shell))) + (let ((extra-args (tramp-get-sh-extra-args shell)) + (p (tramp-get-connection-process vec))) ;; The readline library can disturb Tramp. For example, the ;; very recent version of libedit, the *BSD implementation of ;; readline, confuses Tramp. So we disable line editing. Since ;; $EDITRC is not supported on all target systems, we must move ;; ~/.editrc temporarily somewhere else. For bash and zsh we ;; have disabled this already during shell invocation, see - ;; `tramp-sh-extra-args'. Bug#39399. + ;; `tramp-sh-extra-args' (Bug#39399). + ;; The shell prompt might not be set yet, so we must read any + ;; prompt via `tramp-barf-if-no-shell-prompt'. (unless extra-args - (tramp-send-command vec "rm -f ~/.editrc.tramp" t) - (tramp-send-command vec "mv -f ~/.editrc ~/.editrc.tramp" t) - (tramp-send-command vec "echo 'edit off' >~/.editrc" t)) + (tramp-send-command vec "rm -f ~/.editrc.tramp" t t) + (tramp-barf-if-no-shell-prompt p 10 "Couldn't find remote shell prompt") + (tramp-send-command + vec "test -e ~/.editrc && mv -f ~/.editrc ~/.editrc.tramp" t t) + (tramp-barf-if-no-shell-prompt p 10 "Couldn't find remote shell prompt") + (tramp-send-command vec "echo 'edit off' >~/.editrc" t t) + (tramp-barf-if-no-shell-prompt + p 10 "Couldn't find remote shell prompt")) ;; It is useful to set the prompt in the following command ;; because some people have a setting for $PS1 which /bin/sh ;; doesn't know about and thus /bin/sh will display a strange @@ -4150,7 +4158,9 @@ file exists and nonzero exit status otherwise." (tramp-shell-quote-argument tramp-end-of-output) shell (or extra-args "")) t) + ;; Reset ~/.editrc. (unless extra-args + (tramp-send-command vec "rm -f ~/.editrc" t) (tramp-send-command vec "test -e ~/.editrc.tramp && mv -f ~/.editrc.tramp ~/.editrc" t)) ;; Check proper HISTFILE setting. We give up when not working. diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a38b3c6e51c..19d36c3a97b 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2555,7 +2555,7 @@ Add operations defined in `HANDLER-alist' to `tramp-file-name-handler'." "Check, whether it is possible to connect the remote host w/o side-effects. This is true, if either the remote host is already connected, or if we are not in completion mode." - (let (tramp-verbose + (let ((tramp-verbose 0) (vec (cond ((tramp-file-name-p vec-or-filename) vec-or-filename) @@ -3431,7 +3431,7 @@ User is always nil." (with-tramp-progress-reporter v 0 (format "Opening directory %s" filename) (let (ls-lisp-use-insert-directory-program start) ;; Silence byte compiler. - ls-lisp-use-insert-directory-program + (ignore ls-lisp-use-insert-directory-program) (tramp-run-real-handler #'insert-directory (list filename switches wildcard full-directory-p)) -- 2.39.5