aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2021-09-12 11:20:33 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-09-14 08:16:15 +0200
commit0beee209778870888c3a80a9ae57e74888bc8e7b (patch)
tree30b0edf10991d4833acd6461be1e848f7668e3e8
parent9346ea9550887ee81de4df3731f8d4ff533f4aed (diff)
downloadbusybox-w32-0beee209778870888c3a80a9ae57e74888bc8e7b.tar.gz
busybox-w32-0beee209778870888c3a80a9ae57e74888bc8e7b.tar.bz2
busybox-w32-0beee209778870888c3a80a9ae57e74888bc8e7b.zip
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.c22
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)
10826 * Refill the input buffer and return the next input character: 10826 * Refill the input buffer and return the next input character:
10827 * 10827 *
10828 * 1) If a string was pushed back on the input, pop it; 10828 * 1) If a string was pushed back on the input, pop it;
10829 * 2) If an EOF was pushed back (g_parsefile->left_in_line < -BIGNUM) 10829 * 2) If we are reading from a string we can't refill the buffer, return EOF.
10830 * or we are reading from a string so we can't refill the buffer,
10831 * return EOF.
10832 * 3) If there is more stuff in this buffer, use it else call read to fill it. 10830 * 3) If there is more stuff in this buffer, use it else call read to fill it.
10833 * 4) Process input up to the next newline, deleting nul characters. 10831 * 4) Process input up to the next newline, deleting nul characters.
10834 */ 10832 */
@@ -10845,21 +10843,9 @@ preadbuffer(void)
10845 popstring(); 10843 popstring();
10846 return __pgetc(); 10844 return __pgetc();
10847 } 10845 }
10848 /* on both branches above g_parsefile->left_in_line < 0.
10849 * "pgetc" needs refilling.
10850 */
10851 10846
10852 /* -90 is our -BIGNUM. Below we use -99 to mark "EOF on read", 10847 if (g_parsefile->buf == NULL) {
10853 * pungetc() may increment it a few times.
10854 * Assuming it won't increment it to less than -90.
10855 */
10856 if (g_parsefile->left_in_line < -90 || g_parsefile->buf == NULL) {
10857 pgetc_debug("preadbuffer PEOF1"); 10848 pgetc_debug("preadbuffer PEOF1");
10858 /* even in failure keep left_in_line and next_to_pgetc
10859 * in lock step, for correct multi-layer pungetc.
10860 * left_in_line was decremented before preadbuffer(),
10861 * must inc next_to_pgetc: */
10862 g_parsefile->next_to_pgetc++;
10863 return PEOF; 10849 return PEOF;
10864 } 10850 }
10865 10851
@@ -10869,10 +10855,8 @@ preadbuffer(void)
10869 again: 10855 again:
10870 more = preadfd(); 10856 more = preadfd();
10871 if (more <= 0) { 10857 if (more <= 0) {
10872 /* don't try reading again */ 10858 g_parsefile->left_in_buffer = g_parsefile->left_in_line = 0;
10873 g_parsefile->left_in_line = -99;
10874 pgetc_debug("preadbuffer PEOF2"); 10859 pgetc_debug("preadbuffer PEOF2");
10875 g_parsefile->next_to_pgetc++;
10876 return PEOF; 10860 return PEOF;
10877 } 10861 }
10878 } 10862 }