From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Shell quoting in Eshell (was: eshell-batch-file) Date: Sun, 09 Jun 2024 22:15:15 +0300 Message-ID: <86bk4a9bcs.fsf@gnu.org> References: <86cyoqbq7m.fsf@gnu.org> <6a0e51ee-f4a2-c668-fcc7-eb83954539d5@gmail.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8465"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Jim Porter Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 09 21:16:24 2024 Return-path: Envelope-to: ged-emacs-devel@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 1sGO1f-0001xr-V1 for ged-emacs-devel@m.gmane-mx.org; Sun, 09 Jun 2024 21:16:23 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGO0i-0003US-C8; Sun, 09 Jun 2024 15:15:24 -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 1sGO0f-0003Tr-TH for emacs-devel@gnu.org; Sun, 09 Jun 2024 15:15:22 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGO0d-0008VF-A2; Sun, 09 Jun 2024 15:15:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=8ShGjpjhS9LTzviy4KJ5rqd7GxjMk/fGnUgBkTpfh4A=; b=R/NIQg7g1Aqo xbRbjyrM/uI+e7ag+b2N7B3Ns3Krm/n9IorKJW0xVifYIGmjn0pQwKCPhuU8PVOzwaKwSB07tfuwD OrrmfjI/Z46psNCZy5v0eSsUhcUUpAiq63CFeu3LC3LlMcHGynjQwXRq2/sqo8dYXW0dHgBZlaFpz sqM1GrT6AMWh9ZNPhiKSktI+ugLAa11e3IXmDRb2uMxjhvnoomiq8j4RnaJKZx2GoXhbjbWBQGdSm HnLTvNJfQGWAk2e6OGIXmQWIQpU6K2RSVoSPS6PI01jJfEzOY/vKSUFU28Puto9w/GucNzr+yufX+ 4ONmMqC8MGvmYoM4t8IG5g==; In-Reply-To: <6a0e51ee-f4a2-c668-fcc7-eb83954539d5@gmail.com> (message from Jim Porter on Sun, 9 Jun 2024 11:55:22 -0700) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:319939 Archived-At: Jim, As long as I have your attention: there's a subtle point with using shell-quote-argument with Eshell. By default, that function adapts itself to the system's default shell. In particular, on Windows the quoting is as expected by cmd.exe and the startup code of Windows programs. This is TRT when invoking the external shell, but it is wrong when invoking programs via Eshell, because Eshell implements quoting rules of a Posix shell. So in many cases one needs to call shell-quote-argument with its 2nd argument non-nil. The problem, in particular with the Eshell test suite, is that that the same utility functions are used with many different commands and many different situations, and so in general it is almost impossible to fix this inside the utility function which actually quotes the arguments, because the function doesn't know how will the command be called and even what are the arguments it is quoting. Curiously, there is already eshell-quote-argument, but it doesn't produce the same effect as shell-quote-argument with 2nd arg non-nil, which is why in esh-proc-tests.el I couldn't use eshell-quote-argument. Any idea why eshell-quote-argument is different? In any case, I suggest at some point to discuss how to handle quoting in a more systematic way, because it was a cause of constant problems when I ran the Eshell tests today and fixed those which failed. Thanks.