[git commit] ash: let ignoreeof only affect interactive shells
Denys Vlasenko
vda.linux at googlemail.com
Tue Sep 14 06:25:58 UTC 2021
commit: https://git.busybox.net/busybox/commit/?id=5726df5f94f973eaa097d9853ceff2bd6b748d97
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
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>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
shell/ash.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/shell/ash.c b/shell/ash.c
index 5743b2377..b12b859d5 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -13508,12 +13508,13 @@ cmdloop(int top)
if (!top || numeof >= 50)
break;
if (!stoppedjobs()) {
+ if (!iflag)
+ break;
if (!Iflag) {
- if (iflag) {
- newline_and_flush(stderr);
- }
+ newline_and_flush(stderr);
break;
}
+ /* "set -o ignoreeof" active, do not exit command loop on ^D */
out2str("\nUse \"exit\" to leave shell.\n");
}
numeof++;
More information about the busybox-cvs
mailing list