From unknown Fri Aug 15 03:56:47 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#71081 <71081@debbugs.gnu.org> To: bug#71081 <71081@debbugs.gnu.org> Subject: Status: 30.0.50; shell-command-on-region outputs boilerplate text on Windows Reply-To: bug#71081 <71081@debbugs.gnu.org> Date: Fri, 15 Aug 2025 10:56:47 +0000 retitle 71081 30.0.50; shell-command-on-region outputs boilerplate text on = Windows reassign 71081 emacs submitter 71081 Ihor Radchenko severity 71081 normal tag 71081 notabug thanks From debbugs-submit-bounces@debbugs.gnu.org Mon May 20 14:33:34 2024 Received: (at submit) by debbugs.gnu.org; 20 May 2024 18:33:34 +0000 Received: from localhost ([127.0.0.1]:44102 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s97pD-0005We-Uy for submit@debbugs.gnu.org; Mon, 20 May 2024 14:33:34 -0400 Received: from lists.gnu.org ([209.51.188.17]:43668) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s97p6-0005WY-JN for submit@debbugs.gnu.org; Mon, 20 May 2024 14:33:29 -0400 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 1s97p1-0000F0-GE for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 14:33:19 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s97oy-0003Hz-Us for bug-gnu-emacs@gnu.org; Mon, 20 May 2024 14:33:18 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id A617E240028 for ; Mon, 20 May 2024 20:33:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716229994; bh=O/OHhLy/CLRNrYhCsNgZUhfJxO8NQ5/MbnkZvvmfhy4=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=Ee0hjejBd6UuuOcp6VwGaO/ZlIlYYw7U5tyCCpkohcgHFTNDYv3DAbNKRiulDGWR4 D59Nty1quF2i6ephw0aBloz+Re97KuJCXe40OsQoEr7HpeleBrTUoXD3q+B4pY4E+p 4h3H4bPYR8xGnjGIRybeROn3Gnrx86qoHasJitZKGfFePgbccagPXxIbUiA0fb7DvF mNlfQoQ0dYI1zvqHYQV7wFiIjJ+u+1UOSoY6HfYy+XdW/mGiG3MVNbHgIxH1McY4ZY uDVHJ/cAS2yuv6KVfI12TcFMczz6Grpni0tCtuEfDzw/ZKW2DVUChdWuxkUvuRYyWw qehjHpQ/hVArA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VjmQy0S9fz6txR for ; Mon, 20 May 2024 20:33:13 +0200 (CEST) From: Ihor Radchenko To: bug-gnu-emacs@gnu.org Subject: 30.0.50; shell-command-on-region outputs boilerplate text on Windows X-Debbugs-Cc: Date: Mon, 20 May 2024 18:34:52 +0000 Message-ID: <875xv8qqlv.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) Hello, On Linux, if I put echo foo into scratch, select it, and run M-x shell-command-on-region sh, I get "foo" in echo area. However, on Windows, the result of M-x shell-command-on-region cmdproxy is Microsoft Windows [Version 10.0.19045.2251] (c) Microsoft Corporation. All rights reserved. c:\Users\johndoe\Org>echo foo foo I expected just "foo". Original bug report: https://list.orgmode.org/orgmode/CACjq+cy8G+EkMgSwr5KWNbN7jjLE3tzqKwbQiTy84ZvJsumMwQ@mail.gmail.com/ AFAIU, the culprit is how cmdproxy handles piped input: cmdproxy -c 'echo foo' works fine, outputting "foo". However (in powershell) echo 'echo foo' | cmdproxy yields the above verbose text - all in stdout. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Mon May 20 15:01:50 2024 Received: (at 71081) by debbugs.gnu.org; 20 May 2024 19:01:50 +0000 Received: from localhost ([127.0.0.1]:44222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s98Gb-0005nW-Ne for submit@debbugs.gnu.org; Mon, 20 May 2024 15:01:50 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46174) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s98GX-0005nJ-Oc; Mon, 20 May 2024 15:01:48 -0400 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 1s98EF-0008FF-VA; Mon, 20 May 2024 14:59:25 -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=OtnTbBLSEfDbLkUuFIZrxckYKNuTyYQFs/cnIWg2ZE4=; b=NQusyWC4ELOJ F8201r9Nd/VEEFXzmT5F3o2C9efp+0rSMXxK8S1qv6JQOziksJzNE0kIueKzwqrotc/gjCgvntnfE LRY2MuChB9zwKDtouYOg1yAveQ6NfuPJCv1BfXTyRVN2qYBCEWlqQ3yupg62/9F0+oBkLcBnqdfP0 HQY8ucZhvlKmz7Nh7FnsY2eM3AKygfJ3VVmF0w3HmDN5jNLEYZN2Lb9CIy4RxtrakYFFFQHXCy/1i f3NqxlAQU+P/k4/aoaDotQQUPi0jp9/JZTehLIvkwnAVw1MJZXsckk8FtoRND/WAjvQEAuDx4ks5t lRa4NY/M681LXLaOohfxMQ==; Date: Mon, 20 May 2024 21:59:21 +0300 Message-Id: <86y1848g3a.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <875xv8qqlv.fsf@localhost> (message from Ihor Radchenko on Mon, 20 May 2024 18:34:52 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71081 Cc: 71081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) tags 71081 notabug thanks > From: Ihor Radchenko > Date: Mon, 20 May 2024 18:34:52 +0000 > > Hello, > > On Linux, if I put > > echo foo > > into scratch, select it, and run M-x shell-command-on-region sh, > I get "foo" in echo area. > > However, on Windows, the result of M-x shell-command-on-region cmdproxy is > > Microsoft Windows [Version 10.0.19045.2251] > (c) Microsoft Corporation. All rights reserved. > > c:\Users\johndoe\Org>echo foo > foo > > I expected just "foo". > > Original bug report: > https://list.orgmode.org/orgmode/CACjq+cy8G+EkMgSwr5KWNbN7jjLE3tzqKwbQiTy84ZvJsumMwQ@mail.gmail.com/ > > AFAIU, the culprit is how cmdproxy handles piped input: > > cmdproxy -c 'echo foo' works fine, outputting "foo". > However (in powershell) echo 'echo foo' | cmdproxy yields the above > verbose text - all in stdout. It is not cmdproxy that does this, it's cmd.exe. cmdproxy is not a shell, it's a simply proxy of the shell that is there to fix some obscure problems (such as some quoting issues). To run shell commands, it eventually invokes cmd.exe. Try echo echo foo | cmd and you will see the same behavior. Conclusion: Windows is not a Posix system. But you already knew that... As for the original bug report: AFAIR, when cmd.exe says "More?", it needs a final newline. Other than that, I don't really understand what is the problem that bug report is trying to solve (I don't use org-babel). If it expects the same behavior from cmd.exe as a Posix shell would produce, the expectation is simply incorrect and unjustified. I see no Emacs bug here. From debbugs-submit-bounces@debbugs.gnu.org Tue May 21 16:18:54 2024 Received: (at 71081) by debbugs.gnu.org; 21 May 2024 20:18:55 +0000 Received: from localhost ([127.0.0.1]:50996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9Vwk-0005yq-I7 for submit@debbugs.gnu.org; Tue, 21 May 2024 16:18:54 -0400 Received: from fout6-smtp.messagingengine.com ([103.168.172.149]:47491) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9Vwi-0005yg-K9 for 71081@debbugs.gnu.org; Tue, 21 May 2024 16:18:53 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 1AF7D138149C; Tue, 21 May 2024 16:18:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 21 May 2024 16:18:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1716322722; x=1716409122; bh=02w5WmfLeuctdEPUeC4ImeANOxdHdp9cFmQkToSh2G0=; b= k30BUV/xFRuu3XhwVbj2JxIkR+pn2Z+Pov6bpWgM9vsyyStqgleOwLJMLnfX0yx/ /DPcxVv22nlbTgcgjl9++2Ykaf04H6wyisVN2wA/nTfXqliTyZk8l86+FmNtm4qD /qRKZaa9rhRYWwS+9vDpCG7ixP2QHCXkrJpQtYsxB796zG3ODsA1j38VaDxPJQNW aph8RjOIYCVatQqztNwt60cPn9TALUFIpatxQC0raDyJKkumC9S0O/RcsZ8YW918 0F4qCb6IX8OOqnILIBLmvqYBYYa09B0Cnflztoi+1s2tj6JvAk07x1LlHKX/UpuZ 1eQy8mtfijnnm8k1KAdhrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1716322722; x= 1716409122; bh=02w5WmfLeuctdEPUeC4ImeANOxdHdp9cFmQkToSh2G0=; b=N FrG74Zhk3UHv+d4UXb7PkDKBPvVsPqP4hcHu6AxnFT+ILdOfDJBVaylSMstETiqe w5fnzguhmotaKsa4haNJ0aNBlgwZ25SzVEtdpYydqtbpteK6hHJTrziYSLDjbUOL A4IIG5DPYUBqbbkCCdrQt47M2dTrU1hLAtW1BRohBEhvRWr8gg+bM6yDf+iG0NrP Jvz1p00M2I/Jh9uPVzS1Ganha5A4MUuobeoD88p1WSjDPJ1ZNiAR2O4nabx2/r0N 5tf4F3mX7zc+ASRRhJ6Ncd1w36qVY5BQ1rMpvtl3Axkc410RpNpOI1PVax3IT7H+ Dml4l3NNfOUPcD3xKao8w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeivddgudeghecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomhepffhm ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg htthgvrhhnpeetudeljeegheetgfehgeejkeeuhedvveeikeeufedtvddtveefhfdvveeg udejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gumhhithhrhiesghhuthhovhdruggvvh X-ME-Proxy: Feedback-ID: i0e71465a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 21 May 2024 16:18:40 -0400 (EDT) Message-ID: <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> Date: Tue, 21 May 2024 23:18:39 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows To: Eli Zaretskii , Ihor Radchenko References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> Content-Language: en-US From: Dmitry Gutov In-Reply-To: <86y1848g3a.fsf@gnu.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71081 Cc: 71081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) On 20/05/2024 21:59, Eli Zaretskii wrote: > If it expects the same behavior from cmd.exe as a Posix > shell would produce, the expectation is simply incorrect and > unjustified. Perhaps we should run something different, or with different arguments, when on Windows? From debbugs-submit-bounces@debbugs.gnu.org Tue May 21 22:30:33 2024 Received: (at 71081) by debbugs.gnu.org; 22 May 2024 02:30:33 +0000 Received: from localhost ([127.0.0.1]:52706 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9bkP-00043N-H4 for submit@debbugs.gnu.org; Tue, 21 May 2024 22:30:33 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41210) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9bkK-00043G-TU for 71081@debbugs.gnu.org; Tue, 21 May 2024 22:30:32 -0400 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 1s9bk7-00004y-Rx; Tue, 21 May 2024 22:30:16 -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=hhxodvCZw4nH85UQD84tXBw8w0CK+GFwWm/y0VfVkFc=; b=jmGICHuQEuMH rz2k0IdvQBdMd/VxjZ3d0Gk7PX7BRsUsmkr8UTBst4qt3KSNByfUjTCmHzZvjvdU+5sPPoOLRFJa9 nLGO2wBwe2lklqTYcAnAUGq1fHtofUtkrjhW30C3W+z0uOtSqXOq3rKzQn35z/5iE47A+Vz+3zpm4 6gwd+Hb0C+w1ZLHMja48WQNaqNTP82b1ee1DFhu1y3cQaQxkbRQ+BLWwl5Y9rqUvXoxwgCP92yOqt pSCwsylMHzkMjNtaNhrf0F71RH9f2u9OyYwr9NPgXYbjUoUHf0TRRlKR/7HCz7bxhbkl3s3xprSBi uyKSdNLJXvLBNkvX2JvRJQ==; Date: Wed, 22 May 2024 05:30:03 +0300 Message-Id: <8634qa8tp0.fsf@gnu.org> From: Eli Zaretskii To: Dmitry Gutov In-Reply-To: <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> (message from Dmitry Gutov on Tue, 21 May 2024 23:18:39 +0300) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081 Cc: yantar92@posteo.net, 71081@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > Date: Tue, 21 May 2024 23:18:39 +0300 > Cc: 71081@debbugs.gnu.org > From: Dmitry Gutov > > On 20/05/2024 21:59, Eli Zaretskii wrote: > > If it expects the same behavior from cmd.exe as a Posix > > shell would produce, the expectation is simply incorrect and > > unjustified. > > Perhaps we should run something different, or with different arguments, > when on Windows? Maybe. But as I said, I don't have a clear understanding of the issue. If I did, perhaps I could give some advice or even suggest a code change if required. From debbugs-submit-bounces@debbugs.gnu.org Wed May 22 07:43:55 2024 Received: (at 71081) by debbugs.gnu.org; 22 May 2024 11:43:55 +0000 Received: from localhost ([127.0.0.1]:55440 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9kNu-0001eT-VO for submit@debbugs.gnu.org; Wed, 22 May 2024 07:43:55 -0400 Received: from mout02.posteo.de ([185.67.36.66]:53601) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9kNs-0001eN-Le for 71081@debbugs.gnu.org; Wed, 22 May 2024 07:43:53 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id A7C1B240104 for <71081@debbugs.gnu.org>; Wed, 22 May 2024 13:43:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716378220; bh=N63Kh0+pCXfd4rw8h2W64KymfhZyprklYdVUanEBeiI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=esM91B4i0PU0VCWAILp46orPHd2HqUN6omVWyGiJzT72Tmny24hhnZ9AFqobVJNlb pmOQhV3F6hQWm+dF6fcZw1w46zXujeM0aK9c52jZR3mbDgidFIq/UOUp5688PKV0W0 kPiERUGlueerk6GCz7GAWLdN5AGdSlWfolQp881B1CYeBljqjTQCSMns4XxllLbv63 CmC+akdc0YVqkvqxdyICkv1X18rB/Cgiikk92S42umlPJs7S9Gks7VUYB61PPerOAw 7sxdPqTspNSmg0GIdvpSibqR6Ja/Ain2mwW5yDk3tb8BPJiz+1Oz9zWSqd2s9GWu9p pVkp1hVUta1DQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VkqFR2kDbz9rxD; Wed, 22 May 2024 13:43:39 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows In-Reply-To: <8634qa8tp0.fsf@gnu.org> References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> Date: Wed, 22 May 2024 11:45:23 +0000 Message-ID: <87le42jcj0.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71081 Cc: Dmitry Gutov , 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> On 20/05/2024 21:59, Eli Zaretskii wrote: >> > If it expects the same behavior from cmd.exe as a Posix >> > shell would produce, the expectation is simply incorrect and >> > unjustified. >> >> Perhaps we should run something different, or with different arguments, >> when on Windows? > > Maybe. But as I said, I don't have a clear understanding of the > issue. If I did, perhaps I could give some advice or even suggest a > code change if required. The goal is to evaluate a shell script - multi-line string. For example, given "cd foo pwd" we need to get the output/value separated from the stderr and stderr output. Org mode uses the approach borrowed from `shell-command-on-region' - passing the script as input to shell process (we use `process-file'). However, as demonstrated by my reproducer, this approach generates more than just script output. In theory, we might pass the script as -c '', but that's not all the story. We also sometimes want to pass the script in chunks (via comint interaction). When using comint, piping commands to shell process input is the only way to keep the shell running as we send it more commands. However, the same problem persists - when sending the very first command, cmd.exe generates its version data, which we cannot easily distinguish from the rest of the output. We cannot easily see stderr either. P.S. CCing Matt, ob-shell maintainer. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Wed May 22 09:33:45 2024 Received: (at 71081) by debbugs.gnu.org; 22 May 2024 13:33:45 +0000 Received: from localhost ([127.0.0.1]:55995 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9m6C-0002x5-H7 for submit@debbugs.gnu.org; Wed, 22 May 2024 09:33:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35522) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9m66-0002wl-SL for 71081@debbugs.gnu.org; Wed, 22 May 2024 09:33:42 -0400 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 1s9m5u-0001CP-Lf; Wed, 22 May 2024 09:33:27 -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=dorx+ZyD2GZiqucbhtgjrxBSBF+G8rMCH7hhU+8KQwg=; b=CViCy5Uzq3Jp 1ez5TbkvzOxZdY3eMVHnko8Te/AOWbLGZdJ90lptej303+wFhGBIfOA2mo3wSvpG0YRHNEXA2gKyN ieIGBK4X4nvK9QWfnnJuZWGnD16tevaLtZbUKclT4M1FIT4nEdenbPNlKDbc6SNfQIYk0OS7w2uWQ fcRIUguY/++3F32x+m+ztU+lcHkkqKmtzrX9oo+YoWWXY2UrnN8efS+VYVaTThQRTgATXI5gKKPz6 O2MI+xAwDGzf4SOxUEl6Wpu68httm8CV0vVmBxmtaJC5GbX9SeKLjHgqr01wq+IdSAXX3x8gaDlnf Q7KkLCQBC+1D2D8ZFZihLQ==; Date: Wed, 22 May 2024 16:33:22 +0300 Message-Id: <86a5ki6kf1.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87le42jcj0.fsf@localhost> (message from Ihor Radchenko on Wed, 22 May 2024 11:45:23 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Ihor Radchenko > Cc: Dmitry Gutov , 71081@debbugs.gnu.org, matt@excalamus.com > Date: Wed, 22 May 2024 11:45:23 +0000 > > The goal is to evaluate a shell script - multi-line string. > > For example, given > > "cd foo > pwd" > > we need to get the output/value separated from the stderr and stderr > output. OK. > Org mode uses the approach borrowed from `shell-command-on-region' - > passing the script as input to shell process (we use > `process-file'). However, as demonstrated by my reproducer, this > approach generates more than just script output. Right. > In theory, we might pass the script as -c '', Won't work on Windows, either, because of the newlines. > When using comint, piping commands to shell process input is the only > way to keep the shell running as we send it more commands. However, the > same problem persists - when sending the very first command, cmd.exe > generates its version data, which we cannot easily distinguish from the > rest of the output. We cannot easily see stderr either. The easiest way of solving this conundrum is to create a temporary batch file, insert all the commands into it, with the first line being @echo off and then submit the name of that batch file to the Windows shell as the sole command-line argument after shell-command-switch. So my recommendation is to do just that, on Windows. From debbugs-submit-bounces@debbugs.gnu.org Wed May 22 10:25:19 2024 Received: (at 71081) by debbugs.gnu.org; 22 May 2024 14:25:19 +0000 Received: from localhost ([127.0.0.1]:56261 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9mu7-0003YH-1J for submit@debbugs.gnu.org; Wed, 22 May 2024 10:25:19 -0400 Received: from mout02.posteo.de ([185.67.36.66]:33183) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9mu5-0003YB-EW for 71081@debbugs.gnu.org; Wed, 22 May 2024 10:25:18 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id D15B4240101 for <71081@debbugs.gnu.org>; Wed, 22 May 2024 16:25:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716387905; bh=pswhxqRMDIXZyLQjpn6sKQPMcXyokaF1daM9U3ukhac=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=qTO9WG+teM+hLTmnvvZ2zQ1EfdRNBCBV8ePh87W7kSeIi0vvnILfVPSGr4eMjlWGY KLmxCKjpJTYr0X/xZd5YG0ER6dzyXbURR3I3G83rCmkKpValmOUaJaAUdXNKRhwv25 416Ptt2AeRuWZuJwgyHUuM4uDHjiwbilCMM2Pd8Tm3JOozc8Aa2pXC5+MHJBgzycHS 1fBcQXrjLOPW6nCqNFAsVon81x/a8VdvbB+F1O8A4QDMzyUm4SnsM1sf+F9QuXvI3p 0Dd7RZyyWozGzSWfwOTspl0H9ZYFcGGX6J01PFu4Yj2v8VtAF6adgrmyx/GsbgCYiq CsFZLTzSpYUGw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Vktqh3bvvz9rxM; Wed, 22 May 2024 16:25:04 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows In-Reply-To: <86a5ki6kf1.fsf@gnu.org> References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> Date: Wed, 22 May 2024 14:26:47 +0000 Message-ID: <875xv5kjmg.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> When using comint, piping commands to shell process input is the only >> way to keep the shell running as we send it more commands. However, the >> same problem persists - when sending the very first command, cmd.exe >> generates its version data, which we cannot easily distinguish from the >> rest of the output. We cannot easily see stderr either. > > The easiest way of solving this conundrum is to create a temporary > batch file, insert all the commands into it, with the first line being > > @echo off > > and then submit the name of that batch file to the Windows shell as > the sole command-line argument after shell-command-switch. So my > recommendation is to do just that, on Windows. May it be something you also want to do for `shell-command-on-region'? At the end, the current Emacs behaviour is unexpected from the user perspective, even though it is a result of the cmd.exe behaviour. If there is a workable workaround, `shell-command-on-region' and Org mode may as well use it; preferably implemented on Emacs side to not duplicate the code. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Wed May 22 10:53:40 2024 Received: (at 71081) by debbugs.gnu.org; 22 May 2024 14:53:40 +0000 Received: from localhost ([127.0.0.1]:56402 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9nLY-0003sh-5p for submit@debbugs.gnu.org; Wed, 22 May 2024 10:53:40 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35692) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s9nLW-0003sb-2q for 71081@debbugs.gnu.org; Wed, 22 May 2024 10:53:39 -0400 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 1s9nLK-0007Ox-Px; Wed, 22 May 2024 10:53:26 -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=DW7dRTA/LcxmcQpESeWfJTZBNaCPoi8C6kmG8+stXhI=; b=Hn+z6nLHqWID v7qsGzVapHaxjbkwebQ1ft1hit/6mGDrhbCxAJ32fBLr0CTdsA5rnFfKPUqgZ1eUUpcLY1YZ/YyOo zkvfFAwhUi1q3JGMW/MO/Y0TXx3bWes5F9mGVADqqzjAbIS8Lhug5ZjWWKiEPAi/W18eP5fWkRHPm ZlYDff6d19TzkZQCBtlILg8UkgMQWJLMdAw/t0t4VKYZfBF23of2oSp8IRWtWyrxatfmERTd+1tY/ dCAT2i7CHEEwQMj76hXOKP+9MJArz+72H/2ubGWWz7zUBqNeg4HcHDHsXBJJoXuMRP6dgY78p7PQ6 kzv4noC/wGXYnVBQdqQdbA==; Date: Wed, 22 May 2024 17:53:22 +0300 Message-Id: <86zfsh6gpp.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <875xv5kjmg.fsf@localhost> (message from Ihor Radchenko on Wed, 22 May 2024 14:26:47 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Ihor Radchenko > Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com > Date: Wed, 22 May 2024 14:26:47 +0000 > > Eli Zaretskii writes: > > > The easiest way of solving this conundrum is to create a temporary > > batch file, insert all the commands into it, with the first line being > > > > @echo off > > > > and then submit the name of that batch file to the Windows shell as > > the sole command-line argument after shell-command-switch. So my > > recommendation is to do just that, on Windows. > > May it be something you also want to do for `shell-command-on-region'? No, because in general the region is some text we want to give a program as input. The usual "program" in these cases is not the shell, but some program that gets the text and processes it in some way. So in most "usual" uses of shell-command-on-region, going through a batch file is an unnecessary overhead. > At the end, the current Emacs behaviour is unexpected from the user > perspective Only if the user is not aware of cmd.exe's different (some say idiosyncratic) behavior wrt commands you pipe into its stdin, and wrt command lines that include newlines. If the user _is_ aware of that, the behavior is very expected. > even though it is a result of the cmd.exe behaviour. If there is a > workable workaround, `shell-command-on-region' and Org mode may as > well use it; preferably implemented on Emacs side to not duplicate > the code. I use Emacs for 30 years, and it's the first time I hear about such a strange use of shell-command-on-region. When I will have finished wondering whatever gave Org developers this crazy idea, my next question would be whether indeed this strange way of using shell-command-on-region is a reason good enough for coding something in core. I tend to think no. I think if Org needs that, Org should solve it for itself. It isn't very hard, is it? When we hear about enough clients for this strange feature, we might consider providing a general solution. From debbugs-submit-bounces@debbugs.gnu.org Thu May 23 08:04:55 2024 Received: (at 71081) by debbugs.gnu.org; 23 May 2024 12:04:56 +0000 Received: from localhost ([127.0.0.1]:59000 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA7Bn-0001ve-FD for submit@debbugs.gnu.org; Thu, 23 May 2024 08:04:55 -0400 Received: from mout02.posteo.de ([185.67.36.66]:41105) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA7Bl-0001vV-4P for 71081@debbugs.gnu.org; Thu, 23 May 2024 08:04:54 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 8F87F240103 for <71081@debbugs.gnu.org>; Thu, 23 May 2024 14:04:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716465880; bh=HJvlEt19RY2UG/IQq39hmYLPLZ6I1vNCO+lMOFdOzLg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=qdA6dULCE6EgA/G/uUpjjtcTQX9Bv9VaEfhHU7oMgf91UnDCyuQJzn/lXUbbXKqAK 56WwsR1KrbvubQT9WRoZR0K7+6q5O72K7nOgab62YbPgcroubf9nEfuQ4VvBEKG/qF cKq0FWORMIeyrULIRs+0ssTvbqaQ4rcoGS5km4Fa5HZPO+MrFzRrg0DRjjuDYEuXnG D1L/YVPV8yOQjF+nY6jrN9Vpfiljl46w4hcb82CZRHb1cYbAJ40UlcXnn4HDKitUJD JPMTnu0hNvOBPFgcp6CtTAEcC3UhzLjG7Ggrxij2W4k9SEkTomR/8RZF9fsQOGXmNZ WVOxqkp2K6pjg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VlRgC64rLz9rxF; Thu, 23 May 2024 14:04:39 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows In-Reply-To: <86zfsh6gpp.fsf@gnu.org> References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> Date: Thu, 23 May 2024 12:06:25 +0000 Message-ID: <87cypcybpa.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> > The easiest way of solving this conundrum is to create a temporary >> > batch file, insert all the commands into it, with the first line being >> > >> > @echo off >> > >> > and then submit the name of that batch file to the Windows shell as >> > the sole command-line argument after shell-command-switch. So my >> > recommendation is to do just that, on Windows. >> >> May it be something you also want to do for `shell-command-on-region'? > > No, because in general the region is some text we want to give a > program as input. The usual "program" in these cases is not the > shell, but some program that gets the text and processes it in some > way. > > So in most "usual" uses of shell-command-on-region, going through a > batch file is an unnecessary overhead. Clear. I am not a big user of shell-command-on-region. Then, what about something like (shell-command-to-string "echo foo\necho bar") On Linux, it yields "foo bar" On Windows, it yields "foo" -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu May 23 09:38:15 2024 Received: (at 71081) by debbugs.gnu.org; 23 May 2024 13:38:15 +0000 Received: from localhost ([127.0.0.1]:59097 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA8e6-0002uP-SN for submit@debbugs.gnu.org; Thu, 23 May 2024 09:38:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48712) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA8e4-0002uJ-Oe for 71081@debbugs.gnu.org; Thu, 23 May 2024 09:38:13 -0400 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 1sA8ds-0003xy-8R; Thu, 23 May 2024 09:38:00 -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=RepLtd29DW9ndTngEXn1hywjrP8bFO8N60ezb2f39YA=; b=WNtBh6IngkcZ /jzaJBzq/x4BD8cwyKvPk2YYBKGvQiJBobTwys50WI0QDg7Ml+e1qImBEH/kDVCBhN+ofL8MCk3QD 1GVdWE4jdDkiVjXW1LWQ9CBE/0UnbrGGvLV+SvdEfVjsyjUhvlJ2QbVMWhCaVwOQq3R4mQYPsi01p rRPjeQYtY0NYb4PSljeWq5A+lxXiOcCHJeUnjVjhgU4kRxmJQlPlX8Ld08vVSOAHT1HIuKpO4RPQ4 brobeBYcrytiYvrs51QPrv7IfQhDZlWGeM7vbv+D4HHCjEqh9MTfBEfKaf4NGb49n/4TIet/LilRD y6lC6tF+fmqecphcFgjNYg==; Date: Thu, 23 May 2024 16:37:55 +0300 Message-Id: <86bk4w4pjg.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87cypcybpa.fsf@localhost> (message from Ihor Radchenko on Thu, 23 May 2024 12:06:25 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> <87cypcybpa.fsf@localhost> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Ihor Radchenko > Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com > Date: Thu, 23 May 2024 12:06:25 +0000 > > Then, what about something like > > (shell-command-to-string "echo foo\necho bar") > > On Linux, it yields > "foo > bar" > > On Windows, it yields > > "foo" Yes, because the Windows shell doesn't support command lines with embedded newlines, so it ignores everything past the first newline. (Actually, there are complicated tricks to do that, but I'll spare you.) Instead, you should do this on Windows: (shell-command-to-string "echo foo && echo bar") This is the documented method of invoking cmd.exe with multiple commands. From debbugs-submit-bounces@debbugs.gnu.org Thu May 23 09:59:23 2024 Received: (at 71081) by debbugs.gnu.org; 23 May 2024 13:59:23 +0000 Received: from localhost ([127.0.0.1]:59148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA8yX-00035X-8m for submit@debbugs.gnu.org; Thu, 23 May 2024 09:59:23 -0400 Received: from mout01.posteo.de ([185.67.36.65]:47707) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA8yN-00035R-Qu for 71081@debbugs.gnu.org; Thu, 23 May 2024 09:59:20 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 924C4240028 for <71081@debbugs.gnu.org>; Thu, 23 May 2024 15:58:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716472739; bh=O/W3js85Rts533GHn/zs9FVUxh9ExU3ppJhdsoLcMuk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=POH4mmvPbSGLT8VjaYnDa2L0dptIQuvRdzQoEbv7WHcJfkE6Bl+QFpFgDJIxNnfNm jJ12ErLChRrgjpEDI57XuRT6aNhm4PIRBDV3LEhjo/slrj2novK9joi7A3ShUaHED+ wio/JeKdZ04KBRIpSlm3lJ7LxAXrlOvjaWq3wsQfYNKM3uLEoM0pJbcHwq6V5FESSU XBlr1+1GUucQdV/nOF0MCX09rZNqUqU/sfrc5388iYW8/EltviiFsbCszIlV0ezCM+ L/SnKm4KtWm4Md1B9aIJXfvgMvzc3PW9am7TKZSRxZfLn5dEHWMkqGVY1Zv+MpGIk8 v56Yhx6jQLEBA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VlVC662Wyz9rxB; Thu, 23 May 2024 15:58:58 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows In-Reply-To: <86bk4w4pjg.fsf@gnu.org> References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> <87cypcybpa.fsf@localhost> <86bk4w4pjg.fsf@gnu.org> Date: Thu, 23 May 2024 14:00:44 +0000 Message-ID: <875xv4y6er.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> On Windows, it yields >> >> "foo" > > Yes, because the Windows shell doesn't support command lines with > embedded newlines, so it ignores everything past the first newline. > (Actually, there are complicated tricks to do that, but I'll spare > you.) Should it be documented in the docstring of `shell-command-to-string'? Currently, it only mentions `shell-quote-argument' and the current behaviour is not expected - there is nothing indicating that one should be careful about newlines (or any other characters passed to system shell). > Instead, you should do this on Windows: > > (shell-command-to-string "echo foo && echo bar") > > This is the documented method of invoking cmd.exe with multiple > commands. Maybe. But `shell-command-on-region' does work with multi-line commands, so it all boils down to implementation details, which are not really described... Why would anyone assume that `shell-command-to-string' is passed as an argument to cmd.exe and not piped as input? Or wise versa. Or maybe by some other means - all the cases have subtle differences. (not just on Windows; on Linux as well; more over, on Linux, different shells have different behaviors wrt input/command argument/script file). -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Thu May 23 10:14:53 2024 Received: (at 71081) by debbugs.gnu.org; 23 May 2024 14:14:53 +0000 Received: from localhost ([127.0.0.1]:59222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA9DZ-0003EJ-DP for submit@debbugs.gnu.org; Thu, 23 May 2024 10:14:53 -0400 Received: from eggs.gnu.org ([209.51.188.92]:40872) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA9DW-0003EC-7r for 71081@debbugs.gnu.org; Thu, 23 May 2024 10:14:51 -0400 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 1sA9DI-0003U4-3g; Thu, 23 May 2024 10:14:36 -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=e7gdvVpbWI/TgExiO3ytaWe5GzBf03a4aykMDoInT0c=; b=ChrJXkUNhOcl DCmpvsKVELG6ESHMr+BEM+R4la9L5EBJdT1EAUG0cHK9lE5mTFelQH0CnpG8+jXFu0J+CzWNd8ITW 6YeGVnGp/sgZLnqkF5GjF2HbDz4Yq9dDn86riNScv+Of1r3WDJPCcr/T/h3tbilJVaWYjvOJZESPZ Gqt/TL8sPjNdYyPNkGYI+9nxUYyRik3Nc5+bFra6y85y1hAST1KrQx7QTT0dE3w07ic2uvYhw4CcJ RyEAaVGVJf+YSIILhAi/MJHg7Z3rvq8pq2sYfWTwkfv+PcZDYADEXstRWX54o2nWVNtt3voCljAOs oipS9JIEKb3vDfJYcDrp6w==; Date: Thu, 23 May 2024 17:14:19 +0300 Message-Id: <867cfk4nus.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <875xv4y6er.fsf@localhost> (message from Ihor Radchenko on Thu, 23 May 2024 14:00:44 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> <87cypcybpa.fsf@localhost> <86bk4w4pjg.fsf@gnu.org> <875xv4y6er.fsf@localhost> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Ihor Radchenko > Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com > Date: Thu, 23 May 2024 14:00:44 +0000 > > Eli Zaretskii writes: > > >> On Windows, it yields > >> > >> "foo" > > > > Yes, because the Windows shell doesn't support command lines with > > embedded newlines, so it ignores everything past the first newline. > > (Actually, there are complicated tricks to do that, but I'll spare > > you.) > > Should it be documented in the docstring of `shell-command-to-string'? We could, but IMO such tangential information belongs to the manual, not to the doc string. We should also somehow avoid the slippery slope of describing all the differences between the Posix shells and the Windows shell. E.g., newlines are also not allowed in Windows file names, but we don't mention that in doc strings of every function that deals with file names. > Currently, it only mentions `shell-quote-argument' and the current > behaviour is not expected - there is nothing indicating that one should > be careful about newlines (or any other characters passed to system > shell). Characters special to a shell always need special attention. And which characters are special to a given shell depends on the shell. Emacs supports special characters for a couple of widely-used shells, but not for all of them. > > Instead, you should do this on Windows: > > > > (shell-command-to-string "echo foo && echo bar") > > > > This is the documented method of invoking cmd.exe with multiple > > commands. > > Maybe. But `shell-command-on-region' does work with multi-line commands, No, it works with multi-line _regions_, since the region is sent to the shell command as input to process. > Why would anyone assume that `shell-command-to-string' is > passed as an argument to cmd.exe and not piped as input? Because the doc string says so: Execute shell command COMMAND and return its output as a string. "Execute COMMAND" means run it as "SHELL -c COMMAND", in any reasonable interpretation. Anything else is not the usual way of running commands. > more over, on Linux, different shells have different behaviors wrt > input/command argument/script file). Same on Windows. Try PowerShell some day. Does it mean we need to document all of that in our documentation? From debbugs-submit-bounces@debbugs.gnu.org Thu May 23 10:34:57 2024 Received: (at 71081) by debbugs.gnu.org; 23 May 2024 14:34:57 +0000 Received: from localhost ([127.0.0.1]:59310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA9Wy-0003TG-Ty for submit@debbugs.gnu.org; Thu, 23 May 2024 10:34:57 -0400 Received: from mout01.posteo.de ([185.67.36.65]:60115) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sA9Ws-0003TA-PQ for 71081@debbugs.gnu.org; Thu, 23 May 2024 10:34:55 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 2607D240027 for <71081@debbugs.gnu.org>; Thu, 23 May 2024 16:34:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1716474878; bh=FuIIHZQF6VblCqb/piOlzPrdANcTjPVzwNVNxcKrgEs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=NmR4eCwcrca8ZhsrDYMGUDj0/peeBJSirYDhqJQrlBKHpb0zqIRVaFygUJAvSO7wN mE6mapZ0VSxrIBLs4i+AOW/01/60AVr4cc7sM3ybSvRjHfXhA5Vypkn9NigKo4Yoog 8EckQKz8A7xqvbU8TG0PrbaLBTJn/TJgpBg50sRCc6egUhwFdrEEUBHRsjU0iklu5D /uw09ls8EtlB2pTM6SzsK0mGQv2pzp8A0ZyzIjst3B+79K+e+yZCFtjv95NEJtkS9H Fc3Lcoh+qi8nCU05TcmQdns47mLSetYILWaDzK1NYwRlVi/Ud1kGHcmeb2vQ/b1wWG 2loLtActr0JYQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VlW0D534lz9rxK; Thu, 23 May 2024 16:34:36 +0200 (CEST) From: Ihor Radchenko To: Eli Zaretskii Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows In-Reply-To: <867cfk4nus.fsf@gnu.org> References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> <87cypcybpa.fsf@localhost> <86bk4w4pjg.fsf@gnu.org> <875xv4y6er.fsf@localhost> <867cfk4nus.fsf@gnu.org> Date: Thu, 23 May 2024 14:36:22 +0000 Message-ID: <87y180wq6x.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 71081 Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Eli Zaretskii writes: >> Should it be documented in the docstring of `shell-command-to-string'? > > We could, but IMO such tangential information belongs to the manual, > not to the doc string. We should also somehow avoid the slippery > slope of describing all the differences between the Posix shells and > the Windows shell. E.g., newlines are also not allowed in Windows > file names, but we don't mention that in doc strings of every function > that deals with file names. Understood. >> Why would anyone assume that `shell-command-to-string' is >> passed as an argument to cmd.exe and not piped as input? > > Because the doc string says so: > > Execute shell command COMMAND and return its output as a string. > > "Execute COMMAND" means run it as "SHELL -c COMMAND", in any > reasonable interpretation. Anything else is not the usual way of > running commands. Another reasonable interpretation is: "do the same thing as if I type COMMAND into shell prompt". But that's me. If you think that my interpretation is uncommon, so be it. >> more over, on Linux, different shells have different behaviors wrt >> input/command argument/script file). > > Same on Windows. Try PowerShell some day. Does it mean we need to > document all of that in our documentation? It would be nice, yes. Without details - just point that there is a difference. Maybe in the "41.3 Creating a Synchronous Process" section of the manual. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at From debbugs-submit-bounces@debbugs.gnu.org Sat May 25 06:03:52 2024 Received: (at 71081-done) by debbugs.gnu.org; 25 May 2024 10:03:52 +0000 Received: from localhost ([127.0.0.1]:42518 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAoFj-0008Ct-NF for submit@debbugs.gnu.org; Sat, 25 May 2024 06:03:52 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAoFh-0008Cj-I4 for 71081-done@debbugs.gnu.org; Sat, 25 May 2024 06:03:50 -0400 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 1sAoFU-0002AU-1R; Sat, 25 May 2024 06:03:36 -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=Kju8nS8yVZcfvJutDd3IoGF2/C2uw4Sr9uISAJ/rT/k=; b=eBKiAPZB4U/Q No7k83I5Kay37oqK9VlWeowgfTFmDFaYj7o+F2PzUsRXAEL8hwryB6r3hyoGWnuAccIlZTnFCgQ6p Qw6KJgnHluouxMiEyxMWIcP6qt5qvCfSMV6H+XdEtaRyZaYpG9cGY8u6iXAvGpCrZw7UNzK+HksTS aPZNznlhekBBB0nLDjZ8MsgYRWm5ziH06kctomHcblG1xY3KH0xLyOKN28FRiNy6b3Dnv4NRpu2SF Pktt4Ye8NTTtHSGDfqlQF5pa0kEptYBqphl13mKtz36HDMEAHWcH0WPhf0YbXouYt471JiUYCxOkK kO/TrH+OP8qV90tUBfLTpA==; Date: Sat, 25 May 2024 13:03:33 +0300 Message-Id: <86msoeyzre.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87y180wq6x.fsf@localhost> (message from Ihor Radchenko on Thu, 23 May 2024 14:36:22 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> <87cypcybpa.fsf@localhost> <86bk4w4pjg.fsf@gnu.org> <875xv4y6er.fsf@localhost> <867cfk4nus.fsf@gnu.org> <87y180wq6x.fsf@localhost> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081-done Cc: dmitry@gutov.dev, 71081-done@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Ihor Radchenko > Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com > Date: Thu, 23 May 2024 14:36:22 +0000 > > Eli Zaretskii writes: > > >> more over, on Linux, different shells have different behaviors wrt > >> input/command argument/script file). > > > > Same on Windows. Try PowerShell some day. Does it mean we need to > > document all of that in our documentation? > > It would be nice, yes. Without details - just point that there is a > difference. Maybe in the "41.3 Creating a Synchronous Process" section > of the manual. Done, and closing the bug. From debbugs-submit-bounces@debbugs.gnu.org Sat May 25 06:04:04 2024 Received: (at 71081-done) by debbugs.gnu.org; 25 May 2024 10:04:04 +0000 Received: from localhost ([127.0.0.1]:42525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAoFw-0008Ds-2w for submit@debbugs.gnu.org; Sat, 25 May 2024 06:04:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58560) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sAoFt-0008D4-QB for 71081-done@debbugs.gnu.org; Sat, 25 May 2024 06:04:02 -0400 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 1sAoFg-0002Bj-U1; Sat, 25 May 2024 06:03:49 -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=Kju8nS8yVZcfvJutDd3IoGF2/C2uw4Sr9uISAJ/rT/k=; b=nNFp3qpsVedQ jqAOmgH4/6nl751ntan8l4bf0wQ4LGQVtl/50aLWsZTZsO+Tl0ear1v9NJBFuPNO0mXAktGX4dM6z vp7i9BXNHeRoy91bs7N+vjo7Vd/qtWd6Lqh+1IOQ52xkDguPp9tVReCRLcdIuusI4wTk0P4crFWq2 DH8zUwSQ0tdRI0om9UZY6RosML+ajL6ZbfsXyXrZ4sNAA3qjP0v3/GNZZuhEWGLKZXPMumQ1nBFDk w6xmjAYNll6kDX0N5lVVUlft0RYFvwQmDZxr8rp21Pw8hF6C+FYKX7W0rfv2AtWK7I0qBCKBqBskP DeEctrymb9eD1VwsZ2qryg==; Date: Sat, 25 May 2024 13:03:46 +0300 Message-Id: <86ikz2yzr1.fsf@gnu.org> From: Eli Zaretskii To: Ihor Radchenko In-Reply-To: <87y180wq6x.fsf@localhost> (message from Ihor Radchenko on Thu, 23 May 2024 14:36:22 +0000) Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows References: <875xv8qqlv.fsf@localhost> <86y1848g3a.fsf@gnu.org> <863fc61b-5ad5-47e5-9f95-96cdcfcfd016@gutov.dev> <8634qa8tp0.fsf@gnu.org> <87le42jcj0.fsf@localhost> <86a5ki6kf1.fsf@gnu.org> <875xv5kjmg.fsf@localhost> <86zfsh6gpp.fsf@gnu.org> <87cypcybpa.fsf@localhost> <86bk4w4pjg.fsf@gnu.org> <875xv4y6er.fsf@localhost> <867cfk4nus.fsf@gnu.org> <87y180wq6x.fsf@localhost> X-Spam-Score: -1.6 (-) X-Debbugs-Envelope-To: 71081-done Cc: dmitry@gutov.dev, 71081-done@debbugs.gnu.org, matt@excalamus.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.6 (--) > From: Ihor Radchenko > Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com > Date: Thu, 23 May 2024 14:36:22 +0000 > > Eli Zaretskii writes: > > >> more over, on Linux, different shells have different behaviors wrt > >> input/command argument/script file). > > > > Same on Windows. Try PowerShell some day. Does it mean we need to > > document all of that in our documentation? > > It would be nice, yes. Without details - just point that there is a > difference. Maybe in the "41.3 Creating a Synchronous Process" section > of the manual. Done, and closing the bug. From unknown Fri Aug 15 03:56:47 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 22 Jun 2024 11:24:15 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator