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

From: Ihor Radchenko <[email-masked]>
Date: Thu, 23 May 2024 14:36:22 +0000

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