bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34123: A patch to fix reading EOF characters in non-interactive mode


From: Lars Ingebrigtsen
Subject: bug#34123: A patch to fix reading EOF characters in non-interactive mode
Date: Mon, 10 Aug 2020 13:56:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> 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 <npostavs@gmail.com> writes:

> Shawn Presser <shawnpresser@gmail.com> writes:
>
>> Notice that it’s currently impossible for non-interactive scripts 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 result
>> 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 == '\n' || c == '\r')
    {
      val = 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?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





reply via email to

[Prev in Thread] Current Thread [Next in Thread]