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: Thu, 23 May 2024 17:14:19 +0300 Message-ID: <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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13989"; 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 Thu May 23 16:15:29 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 1sA9E8-0003Pl-VB for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 23 May 2024 16:15:29 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sA9Dn-0005MP-PV; Thu, 23 May 2024 10:15:07 -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 1sA9Dd-0005Jr-Lb for bug-gnu-emacs@gnu.org; Thu, 23 May 2024 10:14:59 -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 1sA9Dc-0003XG-4h for bug-gnu-emacs@gnu.org; Thu, 23 May 2024 10:14:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sA9Di-0003Ex-3Z for bug-gnu-emacs@gnu.org; Thu, 23 May 2024 10:15: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: Thu, 23 May 2024 14:15: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.171647369312423 (code B ref 71081); Thu, 23 May 2024 14:15:02 +0000 Original-Received: (at 71081) by debbugs.gnu.org; 23 May 2024 14:14:53 +0000 Original-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 Original-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 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 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==; In-Reply-To: <875xv4y6er.fsf@localhost> (message from Ihor Radchenko on Thu, 23 May 2024 14:00:44 +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:285713 Archived-At: > 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?