[PATCH 3/3] ash: let ignoreeof only affect interactive shells

Ron Yorston rmy at pobox.com
Sun Sep 12 10:21:48 UTC 2021


Commit fb7d6c89 from Harald van Dijk's gwsh variant of ash
(https://github.com/hvdijk/gwsh):

    ignoreeof is documented as only having an effect for interactive shells,
    but is implemented as having mostly the same effect for interactive
    shells as for non-interactive shells. Change the implementation to match
    the documentation.

    Test case:

      $SHELL -o ignoreeof /dev/null

function                                             old     new   delta
cmdloop                                              359     361      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 2/0)                 Total: 2 bytes

Signed-off-by: Ron Yorston <rmy at pobox.com>
---
 shell/ash.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/shell/ash.c b/shell/ash.c
index 62e1a4c7e..364ca1cc7 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13504,13 +13504,14 @@ cmdloop(int top)
 			if (!top || numeof >= 50)
 				break;
 			if (!stoppedjobs()) {
-				if (!Iflag) {
-					if (iflag) {
-						newline_and_flush(stderr);
-					}
+				if (!iflag)
+					break;
+				else if (Iflag)
+					out2str("\nUse \"exit\" to leave shell.\n");
+				else {
+					newline_and_flush(stderr);
 					break;
 				}
-				out2str("\nUse \"exit\" to leave shell.\n");
 			}
 			numeof++;
 		} else {
-- 
2.31.1



More information about the busybox mailing list