diff options
author | Ron Yorston <rmy@pobox.com> | 2021-09-12 11:21:48 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-09-14 08:25:58 +0200 |
commit | 5726df5f94f973eaa097d9853ceff2bd6b748d97 (patch) | |
tree | ce8fda0d1d224afa183fc13b44ddc365715907a4 | |
parent | 50239a665c88f5a95ce41146804500f5da90b19e (diff) | |
download | busybox-w32-5726df5f94f973eaa097d9853ceff2bd6b748d97.tar.gz busybox-w32-5726df5f94f973eaa097d9853ceff2bd6b748d97.tar.bz2 busybox-w32-5726df5f94f973eaa097d9853ceff2bd6b748d97.zip |
ash: let ignoreeof only affect interactive shells
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@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 7 |
1 files 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) | |||
13508 | if (!top || numeof >= 50) | 13508 | if (!top || numeof >= 50) |
13509 | break; | 13509 | break; |
13510 | if (!stoppedjobs()) { | 13510 | if (!stoppedjobs()) { |
13511 | if (!iflag) | ||
13512 | break; | ||
13511 | if (!Iflag) { | 13513 | if (!Iflag) { |
13512 | if (iflag) { | 13514 | newline_and_flush(stderr); |
13513 | newline_and_flush(stderr); | ||
13514 | } | ||
13515 | break; | 13515 | break; |
13516 | } | 13516 | } |
13517 | /* "set -o ignoreeof" active, do not exit command loop on ^D */ | ||
13517 | out2str("\nUse \"exit\" to leave shell.\n"); | 13518 | out2str("\nUse \"exit\" to leave shell.\n"); |
13518 | } | 13519 | } |
13519 | numeof++; | 13520 | numeof++; |