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#48940: 27.2; regression: "emacs --script /dev/stdin" parses the script incorrectly when /dev/stdin is a pipe Date: Sun, 13 Jun 2021 13:26:23 +0300 Message-ID: <83pmwq6oxc.fsf@gnu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11757"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48940@debbugs.gnu.org To: "Bryan C. Mills" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jun 13 12:27:20 2021 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 1lsNKp-0002mn-Tu for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Jun 2021 12:27:19 +0200 Original-Received: from localhost ([::1]:54658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsNKo-0005AU-SZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Jun 2021 06:27:18 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsNKa-00059I-0G for bug-gnu-emacs@gnu.org; Sun, 13 Jun 2021 06:27:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59399) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsNKY-0000uR-Lt for bug-gnu-emacs@gnu.org; Sun, 13 Jun 2021 06:27:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lsNKY-0004Q3-I7 for bug-gnu-emacs@gnu.org; Sun, 13 Jun 2021 06:27: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: Sun, 13 Jun 2021 10:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48940 X-GNU-PR-Package: emacs Original-Received: via spool by 48940-submit@debbugs.gnu.org id=B48940.162357999716954 (code B ref 48940); Sun, 13 Jun 2021 10:27:02 +0000 Original-Received: (at 48940) by debbugs.gnu.org; 13 Jun 2021 10:26:37 +0000 Original-Received: from localhost ([127.0.0.1]:42712 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsNK8-0004PM-Sp for submit@debbugs.gnu.org; Sun, 13 Jun 2021 06:26:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsNK7-0004P6-AU for 48940@debbugs.gnu.org; Sun, 13 Jun 2021 06:26:35 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:39070) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsNK1-0000a7-UO; Sun, 13 Jun 2021 06:26:29 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:2339 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsNK1-0004Tf-I0; Sun, 13 Jun 2021 06:26:29 -0400 In-Reply-To: (bug-gnu-emacs@gnu.org) 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" Xref: news.gmane.io gmane.emacs.bugs:208415 Archived-At: > Date: Wed, 9 Jun 2021 16:31:36 -0400 > From: "Bryan C. Mills" via "Bug reports for GNU Emacs, > the Swiss army knife of text editors" > > `emacs --script /dev/stdin` worked reliably for me on Emacs 24 through 26. > > As of Emacs 27, it no longer works reliably — depending on the script contents, > it either fails with spurious errors or silently exits without > finishing the script. > > > In the following bash interaction, all three emacs invocations > *should* run the same script. > The third invocation demonstrates the bug: when /dev/stdin is a pipe from `cat` > (instead of the script.el file directly), the script is no longer interpreted. > With other scripts, I get various errors, seemingly due to `;` or `"` > characters being > dropped or ignored from the input. > > ``` > $ cat script.el | cat /dev/stdin > (print "Hello emacs!") > > $ emacs --no-init-file --no-site-file --script script.el > > "Hello emacs!" > > $ emacs --no-init-file --no-site-file --script /dev/stdin > "Hello emacs!" > > $ cat script.el | emacs --no-init-file --no-site-file --script /dev/stdin > > $ echo $? > 0 > > $ > ``` > > This reproduces with the GNU Emacs 27.1 currently packaged on Debian Testing, > as well as the Google build of GNU Emacs 27.2 from which I produced > the report below. I see the problem, but it happens for me in Emacs 26 and Emacs 25 as well, so I'm not sure this is new, or why it works for you in older versions. Maybe Debian included some local patches in those older versions? (My old Emacs versions were built from the unmodified upstream sources.) AFAICS, the problem seems to be that load-with-code-conversion calls insert-file-contents, and the latter comes up with an empty buffer in the problematic case. It is notoriously hard to debug a program whose standard input was redirected from a pipe of another program, so I couldn't see why the above happens. If someone could step in a debugger through insert-file-contents in this case and describe what's going on there, or tell how to do that when Emacs is invoked like this, maybe we could make some progress. Thanks.