bug-bash
[Top][All Lists]
Advanced

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

Re: EOF not disabled in readline


From: Dale R. Worley
Subject: Re: EOF not disabled in readline
Date: Sun, 26 Jul 2020 02:27:29 -0400

Grisha Levit <grishalevit@gmail.com> writes:
> It seems that disabling the EOF character does not have an effect on
> readline. For example:
>
>     $ stty sane
>     $ stty eof undef
>     $ ^D
>     Use "logout" to leave the shell.
>     $ read -e; echo $?
>     ^D
>     1

That's messy!

When you execute "read -e", you get "If the standard input is coming
from a terminal, readline (see READLINE above) is used to obtain the
line."

In readline, "Line editing is also used when using the -e option to the
read builtin.  By default, the line editing commands are similar to those
of Emacs."

But of course, in Emacs, C-d is "delete forward character", and that is
duplicated in readline:
       delete-char (C-d)
              Delete the character at point.  If point is at the beginning  of
              the  line,  there  are  no  characters in the line, and the last
              character typed was not bound to delete-char, then return EOF.

So when you type C-d, it goes into bash as a character, readline reads
it, and returns EOF to its caller, "read".  And for "read", "The return
code  is  zero,  unless  end-of-file  is encountered ...".

You can verify that analysis by running your example, but instead of
typing a single C-d, type X C-b C-d, and see that that C-d deletes the
X, rather than causing readline to return EOF.

Dale



reply via email to

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