bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#63539: 29.0.90; TRAMP fails to detect shell prompts containing ]


From: Spencer Baugh
Subject: bug#63539: 29.0.90; TRAMP fails to detect shell prompts containing ]
Date: Tue, 16 May 2023 16:06:42 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

Spencer Baugh <sbaugh@janestreet.com> writes:
> Michael Albinus <michael.albinus@gmx.de> writes:
>
>> Spencer Baugh <sbaugh@janestreet.com> writes:
>>
>> Hi Spencer,
>>
>>> Attempting to ssh to a machine with a prompt like:
>>>
>>> [user@hostname] foo/bar/path $
>>>
>>> will hang, because TRAMP thinks that the prompt ends at the "]", not the
>>> "$".
>>>
>>> I guess this is because TRAMP supports prompts like "[foo bar baz]" with
>>> no trailing $.  And it isn't greedy when reading the prompt, so it stops
>>> at the first "]".
>>>
>>> One can work around this by configuring the machine's prompt, but []
>>> seem relatively common in prompts (in my personal experience), and it
>>> would be nice if this worked by default.  (So far I've only seen [] in
>>> custom prompts but there are probably some OSs/distributions with [] in
>>> their prompt by default)
>>
>> What's wrong with the recipe for your remote .profile:
>>
>> [[ $TERM == "dumb" ]] && PS1='$ ' && return
>>
>> The Tramp manual gives an extended version of the recipe, which handles
>> also the zsh line editing problem, but you see the idea.
>
> [] seem relatively common in prompts (in my personal experience), and it
> would be nice if this worked by default.
>
> Just as an additional point, I'm not always connecting to hosts that I
> can trivially change the .profile for.

The RHEL (and Fedora maybe?) prompt by default contains [].  It looks
like:

[sbaugh@hostname ~]$

TRAMP connections to RHEL seems *pretty* important to support by
default.

TRAMP is only working on such hosts today because of the fallback to
shell-prompt-pattern, which doesn't treat [] as a prompt character.

But such machines' prompts stop working if they add color, which
shell-prompt-pattern also doesn't support (namely that regex doesn't
support escape sequences appearing after the prompt, which are necessary
to clear the coloring).

So actually, how about setting shell-prompt-pattern to the following?
All it does is add support for escape characters after the prompt in
shell-prompt-pattern.  That would make my use case work.

(setopt shell-prompt-pattern (rx (* (not (any "#$%>\n")))
      (any "#$%>")
      (* blank)
      ;; Escape characters.
      (* "^[[" (* (any ";" digit)) alpha (* blank))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]