ash: make interactive ^C break out of PS2 mode

Based on patch by Joachim Nilsson <troglobit@gmail.com>

function                                             old     new   delta
pgetc                                                570     547     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2020-11-16 13:09:37 +01:00
parent dc9c10a7b2
commit 4ac35a30db

View File

@ -10593,7 +10593,7 @@ preadfd(void)
g_parsefile->next_to_pgetc = buf; g_parsefile->next_to_pgetc = buf;
#if ENABLE_FEATURE_EDITING #if ENABLE_FEATURE_EDITING
retry: /* retry: */
if (!iflag || g_parsefile->pf_fd != STDIN_FILENO) if (!iflag || g_parsefile->pf_fd != STDIN_FILENO)
nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1); nr = nonblock_immune_read(g_parsefile->pf_fd, buf, IBUFSIZ - 1);
else { else {
@ -10615,15 +10615,14 @@ preadfd(void)
if (nr == 0) { if (nr == 0) {
/* ^C pressed, "convert" to SIGINT */ /* ^C pressed, "convert" to SIGINT */
write(STDOUT_FILENO, "^C", 2); write(STDOUT_FILENO, "^C", 2);
raise(SIGINT);
if (trap[SIGINT]) { if (trap[SIGINT]) {
buf[0] = '\n'; buf[0] = '\n';
buf[1] = '\0'; buf[1] = '\0';
raise(SIGINT);
return 1; return 1;
} }
exitstatus = 128 + SIGINT; exitstatus = 128 + SIGINT;
bb_putchar('\n'); return -1;
goto retry;
} }
if (nr < 0) { if (nr < 0) {
if (errno == 0) { if (errno == 0) {