From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#34123: A patch to fix reading EOF characters in non-interactive mode Date: Mon, 10 Aug 2020 13:56:11 +0200 Message-ID: <87tuxa67fo.fsf@gnus.org> References: <8336pqcd3l.fsf@gnu.org> <831s5ac5qy.fsf@gnu.org> <83zhryaq09.fsf@gnu.org> <83tvi29fsb.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1610"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Shawn Presser , 34123@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 10 13:57:10 2020 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 1k56QQ-0000Gh-6V for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Aug 2020 13:57:10 +0200 Original-Received: from localhost ([::1]:48920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k56QP-00027t-7w for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 10 Aug 2020 07:57:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k56QI-00027j-PJ for bug-gnu-emacs@gnu.org; Mon, 10 Aug 2020 07:57:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51415) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k56QI-0005OK-GR for bug-gnu-emacs@gnu.org; Mon, 10 Aug 2020 07:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1k56QI-00013L-Af for bug-gnu-emacs@gnu.org; Mon, 10 Aug 2020 07:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Aug 2020 11:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34123 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 34123-submit@debbugs.gnu.org id=B34123.15970605853990 (code B ref 34123); Mon, 10 Aug 2020 11:57:02 +0000 Original-Received: (at 34123) by debbugs.gnu.org; 10 Aug 2020 11:56:25 +0000 Original-Received: from localhost ([127.0.0.1]:34728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k56Pg-00012H-Pn for submit@debbugs.gnu.org; Mon, 10 Aug 2020 07:56:25 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:46816) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k56Pf-000124-01 for 34123@debbugs.gnu.org; Mon, 10 Aug 2020 07:56:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID :In-Reply-To:Date:References:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=m+tShq0QmrZI/wkJaJ2c0PoMuPiZvMYDx3wJncH58gw=; b=NJODheGb8LrIFXsNrXyFoIGAWN muWZz2/SJbKQ5rNV+r80+UvYW1STG9qrA2EXwDtJL/vMcvTJl6120l/2t0NVWHvgkAAqTuHIDrN0A BDuYh2Y+7kyI3Nyx5zEYYM9+wPS6YffFjTv9iKzopG4XF30H79pp8VpH+FJaEgIejna0=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k56PU-0003X4-Rq; Mon, 10 Aug 2020 13:56:16 +0200 In-Reply-To: <83tvi29fsb.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 21 Jan 2019 17:44:20 +0200") 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:184491 Archived-At: Eli Zaretskii writes: > I'm still considering the implications of your suggestion on the other > use cases. One possible alternative would be to add a function that > will clear the error condition, and let users/Lisp programs call it. > This way, the default response to EOF will remain intact. > > Perhaps someone else will chime in with opinions and ideas. And then Noam answered a few months later: Noam Postavsky writes: > Shawn Presser writes: > >> Notice that it=E2=80=99s currently impossible for non-interactive script= s to >> recover from EOF when reading from tty. After the user sends an EOF >> character by pressing C-d, calling read-from-minibuffer will always resu= lt >> in an error. > > This isn't quite true, see the attached script which catches the error > and only exits after two EOFs. Shawn, does Noam's solution work for you? Noam also had this suggestion: >> xfree (line); >> - error ("Error reading from stdin"); >> + clearerr(stdin); >> + return Qnil; > > I think it would make sense to change that error to be an end-of-file > error, to make it easier to catch (having to examine the error message, > as I did in my script is not so nice). And I think that's true? It happens here in read_minibuf_noninteractive: if (len || c =3D=3D '\n' || c =3D=3D '\r') { val =3D make_string (line, len); xfree (line); } else { xfree (line); error ("Error reading from stdin"); } So I think that error can only happen on an end-of-file? Anybody objecting to changing that to and end-of-file error? --=20 (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no