From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#54487: 29.0.50; connection-local value for `shell-file-name' not set in Dired buffers over Tramp Date: Mon, 21 Mar 2022 11:25:28 +0100 Message-ID: <87y213bo13.fsf@gmx.de> References: 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="40857"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54487@debbugs.gnu.org To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 21 11:26:20 2022 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 1nWFEx-000AOS-8g for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Mar 2022 11:26:19 +0100 Original-Received: from localhost ([::1]:43058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nWFEr-0007R8-Ae for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 21 Mar 2022 06:26:13 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:40954) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nWFEg-0007QR-Pc for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2022 06:26:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nWFEg-0002Zr-0d for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2022 06:26:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nWFEf-0002Kf-PO for bug-gnu-emacs@gnu.org; Mon, 21 Mar 2022 06:26:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Mar 2022 10:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54487 X-GNU-PR-Package: emacs Original-Received: via spool by 54487-submit@debbugs.gnu.org id=B54487.16478583408932 (code B ref 54487); Mon, 21 Mar 2022 10:26:01 +0000 Original-Received: (at 54487) by debbugs.gnu.org; 21 Mar 2022 10:25:40 +0000 Original-Received: from localhost ([127.0.0.1]:35945 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nWFEJ-0002K0-IX for submit@debbugs.gnu.org; Mon, 21 Mar 2022 06:25:40 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:47959) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nWFEG-0002Jl-TC for 54487@debbugs.gnu.org; Mon, 21 Mar 2022 06:25:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1647858330; bh=yWAREDN3gJDQf55xiKgLseIha/pQtndFLBDAb2rCTJI=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=UHtkk7g22ldlPUyj2vh3PhjZ4FwggxITXgg73mUDqWvlC6CuAWNyqHLdDFZHiPwHc nwbl977CmRi+D/XWXzOg0rkg8xQFpeWFlxqyWPQbqw6AtZysLuMhl1+BfP5uHJXtkk dhqg2+10Zh+psih5dbo5J98Lyi38CLGMiGwc/xuA= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([79.140.118.124]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MSKuA-1ncopG0GHA-00Scn3; Mon, 21 Mar 2022 11:25:30 +0100 In-Reply-To: (Jim Porter's message of "Sun, 20 Mar 2022 21:58:56 -0700") X-Provags-ID: V03:K1:BQO/pW4Gonnq+Lo2ZFvpLWaYgCUBI0XP0pTmT+cfysKKQfn6Kdb vH+2Sxl1BTWBd55nV+53OAJ8CMLUv/03cdfI3/ozgzsFvQ1sI3f3OA57ohVFhNTjniaIl6l Zf3TduZ2KisxSmiJIxZ3h735jPnppLwMUk6WVf2EMgCj3BQzGG9vjiBPmBRWZ7srdJnzJA+ FqneGMmaogAvqm7THf3nQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:qXZyECPX+1Y=:3lgFr2dzFA6GLNannqYbx+ 6SwafHIef+z/7q/m1p/IANu/WAh9+i5Oypr1hIaRTE6svTI7ejFbaxuzb9esarNChgCdodXa6 +2qYy9yk32WQoB9e93WnqbFStR7nhDvb4uVlHieK0IzZT2dVr98xErBFwKJCSmPvPmSpngKo0 1P1fD0ZfjrHL/Oe3/GGsiIs2X97U2qYP977e/pJxrmk/uXbiPlo2NlrmLfJET5XQpvmHfERCr ewMFm+SJvdjTs4msEGwzrrZbM+pdcU1fs0EwXXKTugnId1C/CPbabqKmuD59sLZzhgCK8HnCY 6QpPQKTlpHAb702Up9aNldaG82Ax0/C8xBY9SnDFbjaeuL1Mr74bP4pE7JZgxudM7J/PJxlew UYPWKJ+VppyEB8VEtDYcVMBC8jXnh80IetqReP7v6aAb8N49CWvAxIi9eFOvK73RZW1XwgYBQ 2yiraXpbiAWw9dzYApdT0p/F5Po+Cayx4HbJFeV3QJTFBdYmKOReVjY3gSUXhCiaGB7pcL7oM IVtUOQ5Nz/b6PP7s/tgmz6zkXL6r034018vMPV3PLAqHle+uIPLi2Dg9M0DvqWiVHR55vyHLa rHYhl4SIDS4filWKL0qOfwq3puH20J3LbNKQSf89q4rDi2jNwe006mw4memg4+svU9M/BVQVE piXbbPMPLXL+FEYX4ju5x7hzGsYK2qv5AwagjaA70V7ihwmwGP5dclRFlaOtqu3SREOwolEBP 7UpKnk8gRwBPy3CJ8GuGI0lcGL8oypq3vHTtFT1KU5k+jCQOC343yYYu5pxj/G2vmz87+kMF 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" Xref: news.gmane.io gmane.emacs.bugs:228656 Archived-At: --=-=-= Content-Type: text/plain Jim Porter writes: Hi Jim, > Hopefully I've summarized the issue correctly in the bug title. To see > this in action, run the following from `emacs -Q' on an MS-Windows > system ("host" in this example is a remote GNU/Linux system): > > C-x C-f /ssh:host:~ > M-x rgrep RET > some text RET RET RET > > The rgrep output will look something like: > > find [...] --null -e "some text" "{}" + > find: paths must precede expression: `^^!^' I confirm the bug, it happens also for me. > You can click the "[...]" to see the full invocation. However, even > without doing that, if you look carefully, you'll notice that the > shell-quoting uses the MS-Windows rules, not that of /bin/sh. For the > MS-Windows shell, spaces are quoted by wrapping the entire argument in > double-quotes ("like this"); for /bin/sh, spaces are escaped via a > backslash (like\ this). > > Presumably, that's because if you eval `shell-file-name' in the Dired > buffer, it reports ".../path/to/cmdproxy.exe". When in a remote > *file*, `shell-file-name' is correctly set to "/bin/sh". It is not a problem of shell-file-name, if you check the Tramp debug buffer you'll see, that a proper shell ("/bin/sh" in my case) is applied. The problem is rather quoting the arguments with shell-quote-argument. It applies the quoting according to the value of system-type. If this is 'ms-dos or 'windows-nt, MS Windows quoting rules are applied. The appended patch fixes this for me, could you pls check? Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment Content-Transfer-Encoding: quoted-printable diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index ccc58e6773..85e872bfc2 100644 =2D-- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el @@ -611,6 +611,11 @@ grep-hello-file (write-region "Copyright\n" nil result)) result)) +(defun grep-shell-quote-argument (argument) + (let ((system-type + (if (file-remote-p default-directory) 'not-windows system-type))= ) + (shell-quote-argument argument))) + ;;;###autoload (defun grep-compute-defaults () "Compute the defaults for the `grep' command. @@ -636,8 +641,8 @@ grep-compute-defaults (intern (or (file-remote-p default-directory) "localhost"))) (host-defaults (assq host-id grep-host-defaults-alist)) (defaults (assq nil grep-host-defaults-alist)) - (quot-braces (shell-quote-argument "{}")) - (quot-scolon (shell-quote-argument ";"))) + (quot-braces (grep-shell-quote-argument "{}")) + (quot-scolon (grep-shell-quote-argument ";"))) ;; There are different defaults on different hosts. They must be ;; computed for every host once. (dolist (setting '(grep-command grep-template @@ -820,7 +825,7 @@ grep-tag-default (defun grep-default-command () "Compute the default grep command for \\[universal-argument] \\[grep] t= o offer." - (let ((tag-default (shell-quote-argument (grep-tag-default))) + (let ((tag-default (grep-shell-quote-argument (grep-tag-default))) ;; This a regexp to match single shell arguments. ;; Could someone please add comments explaining it? (sh-arg-re @@ -963,7 +968,7 @@ grep-expand-keywords ("" . files) ("" . (null-device)) ("" . excl) - ("" . (shell-quote-argument (or regexp "")))) + ("" . (grep-shell-quote-argument (or regexp "")))) "List of substitutions performed by `grep-expand-template'. If car of an element matches, the cdr is evalled in order to get the substitution string. @@ -1134,10 +1139,10 @@ lgrep (mapconcat (lambda (ignore) (cond ((stringp ignore) - (shell-quote-argument ignor= e)) + (grep-shell-quote-argument = ignore)) ((consp ignore) (and (funcall (car ignore) = dir) - (shell-quote-argument + (grep-shell-quote-argu= ment (cdr ignore)))))) grep-find-ignored-files " --exclude=3D"))) @@ -1245,44 +1250,44 @@ rgrep-default-command (grep-expand-template grep-find-template regexp - (concat (shell-quote-argument "(") + (concat (grep-shell-quote-argument "(") " " find-name-arg " " (mapconcat - #'shell-quote-argument + #'grep-shell-quote-argument (split-string files) (concat " -o " find-name-arg " ")) " " - (shell-quote-argument ")")) + (grep-shell-quote-argument ")")) dir (concat (and grep-find-ignored-directories (concat "-type d " - (shell-quote-argument "(") - ;; we should use shell-quote-argument here + (grep-shell-quote-argument "(") + ;; we should use grep-shell-quote-argument here " -path " - (mapconcat (lambda (d) (shell-quote-argument (concat "*/= " d))) + (mapconcat (lambda (d) (grep-shell-quote-argument (conca= t "*/" d))) (rgrep-find-ignored-directories dir) " -o -path ") " " - (shell-quote-argument ")") + (grep-shell-quote-argument ")") " -prune -o ")) (and grep-find-ignored-files - (concat (shell-quote-argument "!") " -type d " - (shell-quote-argument "(") - ;; we should use shell-quote-argument here + (concat (grep-shell-quote-argument "!") " -type d " + (grep-shell-quote-argument "(") + ;; we should use grep-shell-quote-argument here " -name " (mapconcat (lambda (ignore) (cond ((stringp ignore) - (shell-quote-argument ignore)) + (grep-shell-quote-argument ignore)) ((consp ignore) (and (funcall (car ignore) dir) - (shell-quote-argument + (grep-shell-quote-argument (cdr ignore)))))) grep-find-ignored-files " -o -name ") " " - (shell-quote-argument ")") + (grep-shell-quote-argument ")") " -prune -o "))))) (defun grep-find-toggle-abbreviation () --=-=-=--