aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/hush.c25
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
1429static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s) 1426static 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;