Subject: Re: bug#71081: 30.0.50; shell-command-on-region outputs boilerplate text on Windows

From: Ihor Radchenko <[email-masked]>
Date: Wed, 22 May 2024 14:26:47 +0000

Eli Zaretskii <[email-masked]> 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 <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>