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: Noam Postavsky
Subject: bug#34123: A patch to fix reading EOF characters in non-interactive mode
Date: Sat, 22 Jun 2019 20:18:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

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.

Attachment: bug-34123-read-script.el
Description: script demoing eof handling

A sample usage:

    $ emacs -Q --script ../bug-34123-read-script.el 
    > one
    line0: "one"
    > 
    EOF1
    > two
    line2: "two"
    > 
    EOF2

>        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).


reply via email to

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