Subject: 25.2; TRAMP vs bash 4.4 / readline 7.0 "bracketed paste" mode
From: Daniel Pittman <[email-masked]>
To: [email-masked]
Date: Fri, 18 Aug 2017 11:22:29 -0400
List-Id: <debbugs-submit.debbugs.gnu.org>

After upgrading a remote system to a version of GNU/Linux that includes bash
4.4 (from Debian/testing), with the readline option `set
enable-bracketed-paste on` in /etc/inputrc, and no personal inputrc,
tramp breaks.

The exact version of `/bin/sh --version` is:
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)

Specifically, it breaks because bash emits "enable bracketed paste" and
"disable bracketed paste" CSI control sequences to the terminal around the
shell prompt.

That results in TRAMP trying to read `<ESC> [ 2 0 0 4 h "..."` as a Lisp
expression, when reading the remote `uname -sr` output, which doesn't work.

Passing the `--noediting` option to the remote shell command resolves the
problem, by disabling readline entirely, but it should also be possible to
augment the `tramp-open-connection-setup-interactive-shell` to issue,
unconditionally, the command:

    bind 'set enable-bracketed-paste off'

That will fail on some variants of /bin/sh (dash, posh, tested, but non-GNU
systems may also show this.)

Ignoring the failure should be harmless, however, both when this is not a
valid internal command, and when it is not known to the bash /
readline version.

In GNU Emacs 25.2.1 (x86_64-apple-darwin16.7.0, NS appkit-1504.83 Version
10.12.6 (Build 16G29))
 of 2017-08-08 built on slippycheeze-macbookpro.roam
Windowing system distributor 'Apple', version 10.3.1504
Configured using:
 'configure --disable-dependency-tracking --disable-silent-rules
 --enable-locallisppath=/Users/slippycheeze/homebrew/share/emacs/site-lisp
 --infodir=/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/info/emacs
 --prefix=/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2 --with-modules
 --with-rsvg --with-xml2 --without-pop --disable-ns-self-contained --with-ns
 --without-x --without-dbus --with-gnutls'

Configured features:
JPEG RSVG NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS NS MODULES

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  diff-hl-flydiff-mode: t
  diff-hl-mode: t
  diff-auto-refine-mode: t
  highlight-parentheses-mode: t
  flyspell-mode: t
  ws-butler-mode: t
  shell-dirtrack-mode: t
  global-undo-tree-mode: t
  undo-tree-mode: t
  global-emojify-mode: t
  emojify-mode: t
  async-bytecomp-package-mode: t
  override-global-mode: t
  midnight-mode: t
  global-auto-revert-mode: t
  display-battery-mode: t
  desktop-save-mode: t
  auto-insert-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  transient-mark-mode: t
  abbrev-mode: t

Recent messages:
Checking 34 files in
/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/emacs/25.2/lisp/emulation...
Checking 167 files in
/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/emacs/25.2/lisp/emacs-lisp...
Checking 24 files in
/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/emacs/25.2/lisp/cedet...
Checking 57 files in
/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/emacs/25.2/lisp/calendar...
Checking 87 files in
/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/emacs/25.2/lisp/calc...
Checking 120 files in
/Users/slippycheeze/homebrew/Cellar/emacs-edge/25.2/share/emacs/25.2/lisp/obsolete...
Checking for load-path shadows...done
user-error: End of history; no default available [2 times]

Features:
(shadow sort footnote mail-extr gnus-msg gnus-art mm-uu mml2015 mm-view
mml-smime smime dig mailcap gnus-sum gnus-group gnus-undo gnus-start
gnus-cloud nnimap nnmail mail-source tls gnutls utf7 netrc nnoo parse-time
gnus-spec gnus-int gnus-range gnus-win emacsbug message rfc822 mml mml-sec
epg
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums pp tabify bs executable
tramp-cmds debug tramp-cache misearch multi-isearch find-func cursor-sensor
diff-mode highlight-parentheses flyspell ispell ws-butler jka-compr skeleton
generic-x cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
align
tramp tramp-compat auth-source eieio eieio-core password-cache
tramp-loaddefs
delight emojify apropos tar-mode json map subr-x ht dracula-theme edmacro
kmacro async-bytecomp advice async cus-edit memoize dash-functional f dash s
assoc use-package diminish bind-key easy-mmode finder-inf cl-macs cl info
package epg-config seq byte-opt gv bytecomp byte-compile cl-extra cconv
midnight icomplete grep compile comint ansi-color ring gnus gnus-ems
nnheader
gnus-util mail-utils mm-util help-fns help-mode easymenu mail-prsvr wid-edit
autorevert filenotify battery desktop frameset autoinsert cus-start cus-load
cl-seq cl-loaddefs pcase cl-lib time-date mule-util tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win ucs-normalize
term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list
newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow
timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak
czech european ethiopic indian cyrillic chinese charscript case-table
epa-hook
jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5 base64
format env code-pages mule custom widget hashtable-print-readable backquote
kqueue cocoa ns multi-tty make-network-process emacs)

Memory information:
((conses 16 582897 386689)
 (symbols 48 46748 3)
 (miscs 40 565 2646)
 (strings 32 160816 184679)
 (string-bytes 1 4469214)
 (vectors 16 96463)
 (vector-slots 8 3893724 189356)
 (floats 8 11677 1729)
 (intervals 56 6386 3416)
 (buffers 976 39))