Subject: bug#31924: Tramp handler timeout with custom method

From: "Sheng Yang" <[email-masked]>
Date: Thu, 24 Oct 2019 00:32:49 -0500

I am using tramp with a custom method, and the commit b70f885d seems to break it.

The usage is with yadm (https://yadm.io/), which prepares a bare git repo to host dotfiles. Here is a minimum script to reproduce the problem:

> #!/bin/bash
> # this file is /tmp/yadm.sh
> shell_opts=""
>  shell_path=""
>  if [[ "$SHELL" =~ bash$ ]]; then
>  shell_opts="--norc"
>  shell_path="\w"
>  elif [[ "$SHELL" =~ [cz]sh$ ]]; then
>  shell_opts="-f"
>  shell_path="%~"
>  fi
> 
>  if [[ "$TERM" == "dumb" ]]; then
>  yadm_prompt=" > "
>  fi
> 
>  # echo "Entering yadm repo"
> 
>  PROMPT="$yadm_prompt" PS1="$yadm_prompt" "$SHELL" $shell_opts
> 
>  echo "Leaving yadm repo"
> # end of yadm.sh

Start emacs with emacs -q, and evaluate the following

> (require 'tramp)
> (add-to-list 'tramp-methods
>  '("yadm"
>  (tramp-login-program "/tmp/yadm.sh")
>  ;; setting the following is crucial
>  (tramp-login-env
>  (("SHELL")
>  ("/bin/sh")))
>  (tramp-remote-shell "/bin/sh")
>  (tramp-remote-shell-args ("-c"))
>  (tramp-connection-timeout 10)))
> 
> (find-file "/yadm::.")

which will lead to a timeout.

Notes:
1. Note setting tramp-login-env with SHELL as "/bin/sh" is crucial for this method to work
2. My default shell is /usr/bin/zsh
3. The tramp buffer also has the mysterious "[?2004h" in the tramp buffer.

Please see log files with (setq tramp-verbose 10) in attachment.

Sheng Yang(杨圣), PhD student
Computer Science Department
University of Maryland, College Park
E-mail: [email-masked]
E-mail (old but still used): [email-masked]