diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-23 23:01:18 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-12-23 23:01:18 +0100 |
commit | 18bcaf374cc8eb7bb1db22a1163dc7d38ee6c7c0 (patch) | |
tree | 042c50cbde938664d0603cd5b8755a14f6ea7e4a | |
parent | 649acb9e235d1fb04e060cf0638bf9d28bb6fd7f (diff) | |
download | busybox-w32-18bcaf374cc8eb7bb1db22a1163dc7d38ee6c7c0.tar.gz busybox-w32-18bcaf374cc8eb7bb1db22a1163dc7d38ee6c7c0.tar.bz2 busybox-w32-18bcaf374cc8eb7bb1db22a1163dc7d38ee6c7c0.zip |
hush: revert "make interactive ^C break out of PS2 mode"
It made ^C break out of the entire shell, if we aren't in PS2 mode.
Need a better idea.
function old new delta
expand_one_var 2344 2353 +9
syntax_error_unterm_ch 21 29 +8
parse_dollar 817 824 +7
parse_stream 2251 2238 -13
fgetc_interactive 249 227 -22
syntax_error_unterm_str 26 - -26
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/2 up/down: 24/-61) Total: -37 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/shell/hush.c b/shell/hush.c index c4381f7a7..e0b519217 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -916,9 +916,6 @@ struct globals { | |||
916 | char opt_c; | 916 | char opt_c; |
917 | #if ENABLE_HUSH_INTERACTIVE | 917 | #if ENABLE_HUSH_INTERACTIVE |
918 | smallint promptmode; /* 0: PS1, 1: PS2 */ | 918 | smallint promptmode; /* 0: PS1, 1: PS2 */ |
919 | # if ENABLE_FEATURE_EDITING | ||
920 | smallint flag_ctrlC; /* when set, suppresses syntax error messages */ | ||
921 | # endif | ||
922 | #endif | 919 | #endif |
923 | smallint flag_SIGINT; | 920 | smallint flag_SIGINT; |
924 | #if ENABLE_HUSH_LOOPS | 921 | #if ENABLE_HUSH_LOOPS |
@@ -1428,10 +1425,7 @@ static void syntax_error_at(unsigned lineno UNUSED_PARAM, const char *msg) | |||
1428 | 1425 | ||
1429 | static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s) | 1426 | static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s) |
1430 | { | 1427 | { |
1431 | #if ENABLE_FEATURE_EDITING | 1428 | bb_error_msg("syntax error: unterminated %s", s); |
1432 | if (!G.flag_ctrlC) | ||
1433 | #endif | ||
1434 | bb_error_msg("syntax error: unterminated %s", s); | ||
1435 | //? source4.tests fails: in bash, echo ${^} in script does not terminate the script | 1429 | //? source4.tests fails: in bash, echo ${^} in script does not terminate the script |
1436 | // die_if_script(); | 1430 | // die_if_script(); |
1437 | } | 1431 | } |
@@ -2642,19 +2636,15 @@ static int get_user_input(struct in_str *i) | |||
2642 | ); | 2636 | ); |
2643 | /* read_line_input intercepts ^C, "convert" it to SIGINT */ | 2637 | /* read_line_input intercepts ^C, "convert" it to SIGINT */ |
2644 | if (r == 0) { | 2638 | if (r == 0) { |
2645 | G.flag_ctrlC = 1; | ||
2646 | raise(SIGINT); | 2639 | raise(SIGINT); |
2647 | } | 2640 | } |
2648 | check_and_run_traps(); | 2641 | check_and_run_traps(); |
2649 | if (r != 0 && !G.flag_SIGINT) | 2642 | if (r != 0 && !G.flag_SIGINT) |
2650 | break; | 2643 | break; |
2651 | /* ^C or SIGINT: return EOF */ | 2644 | /* ^C or SIGINT: repeat */ |
2652 | /* bash prints ^C even on real SIGINT (non-kbd generated) */ | 2645 | /* bash prints ^C even on real SIGINT (non-kbd generated) */ |
2653 | write(STDOUT_FILENO, "^C\n", 3); | 2646 | write(STDOUT_FILENO, "^C\n", 3); |
2654 | G.last_exitcode = 128 | SIGINT; | 2647 | G.last_exitcode = 128 | SIGINT; |
2655 | i->p = NULL; | ||
2656 | i->peek_buf[0] = r = EOF; | ||
2657 | return r; | ||
2658 | } | 2648 | } |
2659 | if (r < 0) { | 2649 | if (r < 0) { |
2660 | /* EOF/error detected */ | 2650 | /* EOF/error detected */ |
@@ -5266,16 +5256,7 @@ static struct pipe *parse_stream(char **pstring, | |||
5266 | ch, ch, !!(ctx.word.o_expflags & EXP_FLAG_ESC_GLOB_CHARS)); | 5256 | ch, ch, !!(ctx.word.o_expflags & EXP_FLAG_ESC_GLOB_CHARS)); |
5267 | if (ch == EOF) { | 5257 | if (ch == EOF) { |
5268 | struct pipe *pi; | 5258 | struct pipe *pi; |
5269 | #if ENABLE_FEATURE_EDITING | 5259 | |
5270 | if (G.flag_ctrlC) { | ||
5271 | /* testcase: interactively entering | ||
5272 | * 'qwe <cr> ^C | ||
5273 | * should not leave input in PS2 mode, waiting to close single quote. | ||
5274 | */ | ||
5275 | G.flag_ctrlC = 0; | ||
5276 | goto parse_error; | ||
5277 | } | ||
5278 | #endif | ||
5279 | if (heredoc_cnt) { | 5260 | if (heredoc_cnt) { |
5280 | syntax_error_unterm_str("here document"); | 5261 | syntax_error_unterm_str("here document"); |
5281 | goto parse_error_exitcode1; | 5262 | goto parse_error_exitcode1; |