2018-03-16 11:45:52 +01:00
|
|
|
---
|
|
|
|
lib/readline/input.c | 7 ++++++-
|
|
|
|
lib/readline/readline.c | 7 +++++++
|
|
|
|
2 files changed, 13 insertions(+), 1 deletion(-)
|
|
|
|
|
|
|
|
--- lib/readline/input.c
|
2019-01-09 14:02:42 +01:00
|
|
|
+++ lib/readline/input.c 2018-11-29 08:29:58.432878428 +0000
|
2023-11-21 08:05:04 +01:00
|
|
|
@@ -801,6 +801,8 @@ rl_read_key (void)
|
2018-03-16 11:45:52 +01:00
|
|
|
return (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
+extern int _rl_read_zero_char_from_tty;
|
|
|
|
+
|
|
|
|
int
|
2019-01-09 14:02:42 +01:00
|
|
|
rl_getc (FILE *stream)
|
|
|
|
{
|
2023-11-21 08:05:04 +01:00
|
|
|
@@ -862,7 +864,10 @@ rl_getc (FILE *stream)
|
2018-03-16 11:45:52 +01:00
|
|
|
/* If zero characters are returned, then the file that we are
|
|
|
|
reading from is empty! Return EOF in that case. */
|
|
|
|
if (result == 0)
|
|
|
|
- return (EOF);
|
|
|
|
+ {
|
|
|
|
+ _rl_read_zero_char_from_tty = 1;
|
|
|
|
+ return (EOF);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
#if defined (__BEOS__)
|
|
|
|
if (errno == EINTR)
|
|
|
|
--- lib/readline/readline.c
|
2019-01-09 14:02:42 +01:00
|
|
|
+++ lib/readline/readline.c 2018-11-29 08:29:58.432878428 +0000
|
2022-09-27 10:03:22 +02:00
|
|
|
@@ -557,6 +557,9 @@ _rl_internal_char_cleanup (void)
|
2018-03-16 11:45:52 +01:00
|
|
|
_rl_erase_entire_line ();
|
|
|
|
}
|
|
|
|
|
|
|
|
+/* Catch EOF from tty, do not return command line */
|
|
|
|
+int _rl_read_zero_char_from_tty = 0;
|
|
|
|
+
|
|
|
|
STATIC_CALLBACK int
|
|
|
|
#if defined (READLINE_CALLBACKS)
|
2019-01-09 14:02:42 +01:00
|
|
|
readline_internal_char (void)
|
2022-09-27 10:03:22 +02:00
|
|
|
@@ -614,6 +617,10 @@ readline_internal_charloop (void)
|
2018-03-16 11:45:52 +01:00
|
|
|
c = rl_read_key ();
|
|
|
|
RL_UNSETSTATE(RL_STATE_READCMD);
|
|
|
|
|
|
|
|
+ /* Return here if terminal is closed */
|
|
|
|
+ if (c == EOF && _rl_read_zero_char_from_tty)
|
|
|
|
+ return (rl_done = 1);
|
|
|
|
+
|
|
|
|
/* look at input.c:rl_getc() for the circumstances under which this will
|
|
|
|
be returned; punt immediately on read error without converting it to
|
|
|
|
a newline; assume that rl_read_key has already called the signal
|