diff options
author | Ron Yorston <rmy@pobox.com> | 2023-04-05 09:31:50 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2023-04-05 09:31:50 +0100 |
commit | d4494ebdeb3340f98a7a79244601b5d574ae36d1 (patch) | |
tree | e9f63b318a9a8b5ffff3b720ce9e0f919067d510 | |
parent | 490bbbb6e3a93045bb40442f5fc76d17a86b596b (diff) | |
download | busybox-w32-d4494ebdeb3340f98a7a79244601b5d574ae36d1.tar.gz busybox-w32-d4494ebdeb3340f98a7a79244601b5d574ae36d1.tar.bz2 busybox-w32-d4494ebdeb3340f98a7a79244601b5d574ae36d1.zip |
ash: special treatment for read builtin
When INT is being trapped the read builtin gets special treatment
in bash. In a top-level interactive shell interrupting the read
with Ctrl-C clears the input and allows the user to enter a new
string. In a subshell Ctrl-C really does interrupt the read and
the trap isn't executed.
zsh works similarly, except that in the latter case the trap is
executed.
dash interrupts the read and executes the trap in both cases.
ksh also interrupts the read in both cases but only executes the
trap in the first.
Implement the bash behaviour.
(GitHub issue #303)
-rw-r--r-- | shell/ash.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index 0863689e8..77670ebb4 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -15462,7 +15462,10 @@ readcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
15462 | write(STDOUT_FILENO, "^C", 2); | 15462 | write(STDOUT_FILENO, "^C", 2); |
15463 | pending_int = 1; | 15463 | pending_int = 1; |
15464 | dotrap(); | 15464 | dotrap(); |
15465 | goto again; | 15465 | if (!(rootshell && iflag)) |
15466 | return (uintptr_t)0; | ||
15467 | else | ||
15468 | goto again; | ||
15466 | } else if (iflag) { | 15469 | } else if (iflag) { |
15467 | raise_interrupt(); | 15470 | raise_interrupt(); |
15468 | } else { | 15471 | } else { |