Subject: Re: bug#24698: [TRAMP] NetBSD stty does not support tab0

From: Michael Albinus <[email-masked]>
Date: Mon, 17 Oct 2016 13:23:29 +0200

iquiw <[email-masked]> writes:

> Tramp sends "stty tab0 ..." to remote host in
> `tramp-open-connection-setup-interactive-shell' function.

"tab0" is POSIX-like, see <https://mac-registration.web.alcatel-lucent.com/mac_list.php>.

> NetBSD stty does not support "tab0" [1], so the command fails.
> As a result, Tramp hangs while connecting to NetBSD host.
>
> According to the manual [2], OpenBSD stty seems not support "tab0" too.
>
> Both supports "tabs" which does same as "tab0".
> It seems "tabs" is supported in other implementations, such as Linux,
> FreeBSD, macOS.

"tabs" is a synonym for tab0, also mentioned in POSIX. But I have no
idea whether the derived "tabs" argument is supported everywhere.
Therefore, I'm reluctant to replace "tab0" blindly by "tabs".

The following patch (based on the development version of Tramp) should
fix this. Could you, pls, check?

> Thanks in advance,
> iku

--8<---------------cut here---------------start------------->8---
*** /home/albinus/src/tramp/lisp/tramp-sh.el.~45897f8f340a07b89bc2f288dec2df0fbfda149e~	2016-10-17 13:16:50.453196769 +0200
--- /home/albinus/src/tramp/lisp/tramp-sh.el	2016-10-17 13:07:37.470127598 +0200
***************
*** 4045,4054 ****
  	(case-fold-search t))
      (tramp-open-shell vec (tramp-get-method-parameter vec 'tramp-remote-shell))
  
!     ;; Disable tab and echo expansion.
      (tramp-message vec 5 "Setting up remote shell environment")
      (tramp-send-command
!      vec "stty tab0 -inlcr -onlcr -echo kill '^U' erase '^H'" t)
      ;; Check whether the echo has really been disabled.  Some
      ;; implementations, like busybox of embedded GNU/Linux, don't
      ;; support disabling.
--- 4045,4054 ----
  	(case-fold-search t))
      (tramp-open-shell vec (tramp-get-method-parameter vec 'tramp-remote-shell))
  
!     ;; Disable echo expansion.
      (tramp-message vec 5 "Setting up remote shell environment")
      (tramp-send-command
!      vec "stty -inlcr -onlcr -echo kill '^U' erase '^H'" t)
      ;; Check whether the echo has really been disabled.  Some
      ;; implementations, like busybox of embedded GNU/Linux, don't
      ;; support disabling.
***************
*** 4164,4173 ****
    (when (string-match "^IRIX64" (tramp-get-connection-property vec "uname" ""))
      (tramp-send-command vec "set +H" t))
  
!   ;; On BSD-like systems, ?\t is expanded to spaces.  Suppress this.
!   (when (string-match "BSD\\|Darwin"
! 		      (tramp-get-connection-property vec "uname" ""))
!     (tramp-send-command vec "stty -oxtabs" t))
  
    ;; Set utf8 encoding.  Needed for Mac OS X, for example.  This is
    ;; non-POSIX, so we must expect errors on some systems.
--- 4164,4174 ----
    (when (string-match "^IRIX64" (tramp-get-connection-property vec "uname" ""))
      (tramp-send-command vec "set +H" t))
  
!   ;; Disable tab expansion.
!   (if (string-match
!        "BSD\\|Darwin" (tramp-get-connection-property vec "uname" ""))
!       (tramp-send-command vec "stty tabs" t)
!     (tramp-send-command vec "stty tab0" t))
  
    ;; Set utf8 encoding.  Needed for Mac OS X, for example.  This is
    ;; non-POSIX, so we must expect errors on some systems.
--8<---------------cut here---------------end--------------->8---