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.bugs Subject: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows Date: Wed, 22 May 2024 16:33:22 +0300 Message-ID: <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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1378"; mail-complaints-to="usenet@ciao.gmane.io" Cc: dmitry@gutov.dev, 71081@debbugs.gnu.org, matt@excalamus.com To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 22 15:34:24 2024 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 1s9m6q-000AZS-GB for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 22 May 2024 15:34:24 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s9m6R-0005mf-DW; Wed, 22 May 2024 09:33:59 -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 1s9m6O-0005lf-SG for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 09:33:56 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s9m6O-0001Fq-K7 for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 09:33:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s9m6U-0002xS-BS for bug-gnu-emacs@gnu.org; Wed, 22 May 2024 09:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 22 May 2024 13:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 71081 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: notabug Original-Received: via spool by 71081-submit@debbugs.gnu.org id=B71081.171638482511355 (code B ref 71081); Wed, 22 May 2024 13:34:02 +0000 Original-Received: (at 71081) by debbugs.gnu.org; 22 May 2024 13:33:45 +0000 Original-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 Original-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 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 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==; In-Reply-To: <87le42jcj0.fsf@localhost> (message from Ihor Radchenko on Wed, 22 May 2024 11:45:23 +0000) 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:285617 Archived-At: > 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.