diff options
author | Ron Yorston <rmy@pobox.com> | 2021-09-12 11:20:33 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-14 08:16:15 +0200 |
commit | 0beee209778870888c3a80a9ae57e74888bc8e7b (patch) | |
tree | 30b0edf10991d4833acd6461be1e848f7668e3e8 | |
parent | 9346ea9550887ee81de4df3731f8d4ff533f4aed (diff) |
ash: fix ignoreeof option
The ignoreeof option should prevent an interactive shell from
exiting on EOF. This hasn't worked in BusyBox ash since commit
727752d2d (ash: better fix for ash -c 'echo 5&' and ash -c 'sleep 5&'
with testcase).
Commit 3b4d04b77e (ash: input: Allow two consecutive calls to pungetc)
pulled in improved support for multiple calls to pungetc from dash,
thus rendering much of commit 727752d2d obsolete. Removing this old
code fixes the problem with ignoreeof.
function old new delta
__pgetc 605 587 -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-18) Total: -18 bytes
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/shell/ash.c b/shell/ash.c index 3524d046e..152b3b46a 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -10826,9 +10826,7 @@ preadfd(void) * Refill the input buffer and return the next input character: * * 1) If a string was pushed back on the input, pop it; - * 2) If an EOF was pushed back (g_parsefile->left_in_line < -BIGNUM) - * or we are reading from a string so we can't refill the buffer, - * return EOF. + * 2) If we are reading from a string we can't refill the buffer, return EOF. * 3) If there is more stuff in this buffer, use it else call read to fill it. * 4) Process input up to the next newline, deleting nul characters. */ @@ -10845,21 +10843,9 @@ preadbuffer(void) popstring(); return __pgetc(); } - /* on both branches above g_parsefile->left_in_line < 0. - * "pgetc" needs refilling. - */ - /* -90 is our -BIGNUM. Below we use -99 to mark "EOF on read", - * pungetc() may increment it a few times. - * Assuming it won't increment it to less than -90. - */ - if (g_parsefile->left_in_line < -90 || g_parsefile->buf == NULL) { + if (g_parsefile->buf == NULL) { pgetc_debug("preadbuffer PEOF1"); - /* even in failure keep left_in_line and next_to_pgetc - * in lock step, for correct multi-layer pungetc. - * left_in_line was decremented before preadbuffer(), - * must inc next_to_pgetc: */ - g_parsefile->next_to_pgetc++; return PEOF; } @@ -10869,10 +10855,8 @@ preadbuffer(void) again: more = preadfd(); if (more <= 0) { - /* don't try reading again */ - g_parsefile->left_in_line = -99; + g_parsefile->left_in_buffer = g_parsefile->left_in_line = 0; pgetc_debug("preadbuffer PEOF2"); - g_parsefile->next_to_pgetc++; return PEOF; } } |