From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.bugs Subject: bug#63539: 29.0.90; TRAMP fails to detect shell prompts containing ] Date: Wed, 17 May 2023 10:04:28 -0400 Message-ID: References: <877ct8w4bs.fsf@gmx.de> <87wn17ukrq.fsf@gmx.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31650"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 63539@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 17 16:06:03 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pzHn0-000800-VX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 17 May 2023 16:06:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pzHm5-0001OD-P1; Wed, 17 May 2023 10:05:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pzHm4-0001My-3n for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 10:05:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pzHm3-00026b-Ra for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 10:05:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pzHm3-0002Bb-Mf for bug-gnu-emacs@gnu.org; Wed, 17 May 2023 10:05:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Spencer Baugh Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 17 May 2023 14:05:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 63539 X-GNU-PR-Package: emacs Original-Received: via spool by 63539-submit@debbugs.gnu.org id=B63539.16843322768326 (code B ref 63539); Wed, 17 May 2023 14:05:03 +0000 Original-Received: (at 63539) by debbugs.gnu.org; 17 May 2023 14:04:36 +0000 Original-Received: from localhost ([127.0.0.1]:50529 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzHlb-0002A6-L1 for submit@debbugs.gnu.org; Wed, 17 May 2023 10:04:36 -0400 Original-Received: from mxout6.mail.janestreet.com ([64.215.233.21]:53497) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzHlZ-00029U-W1 for 63539@debbugs.gnu.org; Wed, 17 May 2023 10:04:34 -0400 In-Reply-To: <87wn17ukrq.fsf@gmx.de> (Michael Albinus's message of "Wed, 17 May 2023 15:53:29 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:261853 Archived-At: --=-=-= Content-Type: text/plain Michael Albinus writes: > Spencer Baugh writes: > > Hi Spencer, > >>>> 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. > > "[whatever]" is covered in Tramp. What isn't covered is your use case > "[user@hostname] foo/bar/path $". Again I want to note that "[user@hostname] $" is the default on RHEL/Fedora machines, which surely are common enough that TRAMP to them needs to be supported out of the box in Emacs. And indeed they work today in Emacs, they only break when the prompt is colored. How about this patch, which is a separate enhancement to shell-prompt-pattern to allow it to match colored prompts? Which is a useful feature for shell-mode, and as a side-effect fixes this bug. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Support-color-in-shell-prompt-pattern.patch Content-Transfer-Encoding: 8bit >From 0f1c35e4c05e021198d75d94ad2dc6b987cc72a2 Mon Sep 17 00:00:00 2001 From: Spencer Baugh Date: Wed, 17 May 2023 09:59:48 -0400 Subject: [PATCH] Support color in shell-prompt-pattern shell-prompt-pattern works well, but it doesn't support escape characters coming after the prompt like tramp-shell-prompt-pattern. This change adds matching for escape characters, and also switches it to be defined with rx for clarity. As a side-effect, this fixes Bug#63539 * lisp/shell.el (shell-prompt-pattern): Switch to rx and allow color codes after the prompt. --- lisp/shell.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lisp/shell.el b/lisp/shell.el index 5cf108bfa3b..16cd5d42998 100644 --- a/lisp/shell.el +++ b/lisp/shell.el @@ -122,9 +122,12 @@ shell-dumb-shell-regexp :type 'regexp :group 'shell) -(defcustom shell-prompt-pattern "^[^#$%>\n]*[#$%>] *" +(defcustom shell-prompt-pattern (rx (* (not (any "#$%>\n"))) + (any "#$%>") + (* blank) + ;; Escape characters. + (* "[" (* (any ";" digit)) alpha (* blank))) "Regexp to match prompts in the inferior shell. -Defaults to \"^[^#$%>\\n]*[#$%>] *\", which works pretty well. This variable is used to initialize `comint-prompt-regexp' in the shell buffer. -- 2.30.2 --=-=-=--