@@ -537,12 +537,13 @@ based on the Tramp and Emacs versions, and should not be set here."
537
537
538
538
; ;;###tramp-autoload
539
539
(defcustom tramp-sh-extra-args
540
- '((" /bash\\ '" . " -norc -noprofile" )
540
+ '((" /bash\\ '" . " -noediting - norc -noprofile" )
541
541
(" /zsh\\ '" . " -f +Z -V" ))
542
542
" Alist specifying extra arguments to pass to the remote shell.
543
543
Entries are (REGEXP . ARGS) where REGEXP is a regular expression
544
544
matching the shell file name and ARGS is a string specifying the
545
- arguments.
545
+ arguments. These arguments shall disable line editing, see
546
+ `tramp-open-shell' .
546
547
547
548
This variable is only used when Tramp needs to start up another shell
548
549
for tilde expansion. The extra arguments should typically prevent the
@@ -4103,6 +4104,19 @@ file exists and nonzero exit status otherwise."
4103
4104
vec 5 (format-message " Opening remote shell `%s' " shell)
4104
4105
; ; Find arguments for this shell.
4105
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
4120
; ; doesn't know about and thus /bin/sh will display a strange
4107
4121
; ; prompt. For example, if $PS1 has "${CWD}" in the value, then
4108
4122
; ; ksh will display the current working directory but /bin/sh
@@ -4136,6 +4150,9 @@ file exists and nonzero exit status otherwise."
4136
4150
(tramp-shell-quote-argument tramp-end-of-output)
4137
4151
shell (or extra-args " " ))
4138
4152
t )
4153
+ (unless extra-args
4154
+ (tramp-send-command
4155
+ vec " test -e ~/.editrc.tramp && mv -f ~/.editrc.tramp ~/.editrc" t ))
4139
4156
; ; Check proper HISTFILE setting. We give up when not working.
4140
4157
(when (and (stringp tramp-histfile-override)
4141
4158
(file-name-directory tramp-histfile-override))
0 commit comments