aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2020-02-05 11:40:52 +0100
committerMichael Albinus2020-02-05 11:40:52 +0100
commit6b00600647c960831706f0c57cf29f53ec80551b (patch)
tree34ad014c5c0674093b0243bb2cf8a3a04806ed3a
parent1759b7d06acad918d439a3f4d25bd9aa77549dd1 (diff)
downloademacs-6b00600647c960831706f0c57cf29f53ec80551b.tar.gz
emacs-6b00600647c960831706f0c57cf29f53ec80551b.zip
Handle problem with *BSD libedit in Tramp
* lisp/net/tramp-sh.el (tramp-sh-extra-args): Add "-noediting" as bash arg. (tramp-open-shell): Provide proper "~/.editrc" if needed. (Bug#39399)
-rw-r--r--lisp/net/tramp-sh.el21
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index b8f3c0d8c82..2e8793056ab 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -537,12 +537,13 @@ based on the Tramp and Emacs versions, and should not be set here."
537 537
538;;;###tramp-autoload 538;;;###tramp-autoload
539(defcustom tramp-sh-extra-args 539(defcustom tramp-sh-extra-args
540 '(("/bash\\'" . "-norc -noprofile") 540 '(("/bash\\'" . "-noediting -norc -noprofile")
541 ("/zsh\\'" . "-f +Z -V")) 541 ("/zsh\\'" . "-f +Z -V"))
542 "Alist specifying extra arguments to pass to the remote shell. 542 "Alist specifying extra arguments to pass to the remote shell.
543Entries are (REGEXP . ARGS) where REGEXP is a regular expression 543Entries are (REGEXP . ARGS) where REGEXP is a regular expression
544matching the shell file name and ARGS is a string specifying the 544matching the shell file name and ARGS is a string specifying the
545arguments. 545arguments. These arguments shall disable line editing, see
546`tramp-open-shell'.
546 547
547This variable is only used when Tramp needs to start up another shell 548This variable is only used when Tramp needs to start up another shell
548for tilde expansion. The extra arguments should typically prevent the 549for tilde expansion. The extra arguments should typically prevent the
@@ -4103,6 +4104,19 @@ file exists and nonzero exit status otherwise."
4103 vec 5 (format-message "Opening remote shell `%s'" shell) 4104 vec 5 (format-message "Opening remote shell `%s'" shell)
4104 ;; Find arguments for this shell. 4105 ;; Find arguments for this shell.
4105 (let ((extra-args (tramp-get-sh-extra-args shell))) 4106 (let ((extra-args (tramp-get-sh-extra-args shell)))
4107 ;; The readline library can disturb Tramp. For example, the
4108 ;; very recent version of libedit, the *BSD implementation of
4109 ;; readline, confuses Tramp. So we disable line editing. Since
4110 ;; $EDITRC is not supported on all target systems, we must move
4111 ;; ~/.editrc temporarily somewhere else. For bash and zsh we
4112 ;; have disabled this already during shell invocation, see
4113 ;; `tramp-sh-extra-args'. Bug#39399.
4114 (unless extra-args
4115 (tramp-send-command vec "rm -f ~/.editrc.tramp" t)
4116 (tramp-send-command vec "mv -f ~/.editrc ~/.editrc.tramp" t)
4117 (tramp-send-command vec "echo 'edit off' >~/.editrc" t))
4118 ;; It is useful to set the prompt in the following command
4119 ;; because some people have a setting for $PS1 which /bin/sh
4106 ;; doesn't know about and thus /bin/sh will display a strange 4120 ;; doesn't know about and thus /bin/sh will display a strange
4107 ;; prompt. For example, if $PS1 has "${CWD}" in the value, then 4121 ;; prompt. For example, if $PS1 has "${CWD}" in the value, then
4108 ;; ksh will display the current working directory but /bin/sh 4122 ;; ksh will display the current working directory but /bin/sh
@@ -4136,6 +4150,9 @@ file exists and nonzero exit status otherwise."
4136 (tramp-shell-quote-argument tramp-end-of-output) 4150 (tramp-shell-quote-argument tramp-end-of-output)
4137 shell (or extra-args "")) 4151 shell (or extra-args ""))
4138 t) 4152 t)
4153 (unless extra-args
4154 (tramp-send-command
4155 vec "test -e ~/.editrc.tramp && mv -f ~/.editrc.tramp ~/.editrc" t))
4139 ;; Check proper HISTFILE setting. We give up when not working. 4156 ;; Check proper HISTFILE setting. We give up when not working.
4140 (when (and (stringp tramp-histfile-override) 4157 (when (and (stringp tramp-histfile-override)
4141 (file-name-directory tramp-histfile-override)) 4158 (file-name-directory tramp-histfile-override))