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>
This commit is contained in:
parent
649acb9e23
commit
18bcaf374c
23
shell/hush.c
23
shell/hush.c
@ -916,9 +916,6 @@ struct globals {
|
|||||||
char opt_c;
|
char opt_c;
|
||||||
#if ENABLE_HUSH_INTERACTIVE
|
#if ENABLE_HUSH_INTERACTIVE
|
||||||
smallint promptmode; /* 0: PS1, 1: PS2 */
|
smallint promptmode; /* 0: PS1, 1: PS2 */
|
||||||
# if ENABLE_FEATURE_EDITING
|
|
||||||
smallint flag_ctrlC; /* when set, suppresses syntax error messages */
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
smallint flag_SIGINT;
|
smallint flag_SIGINT;
|
||||||
#if ENABLE_HUSH_LOOPS
|
#if ENABLE_HUSH_LOOPS
|
||||||
@ -1428,9 +1425,6 @@ static void syntax_error_at(unsigned lineno UNUSED_PARAM, const char *msg)
|
|||||||
|
|
||||||
static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s)
|
static void syntax_error_unterm_str(unsigned lineno UNUSED_PARAM, const char *s)
|
||||||
{
|
{
|
||||||
#if ENABLE_FEATURE_EDITING
|
|
||||||
if (!G.flag_ctrlC)
|
|
||||||
#endif
|
|
||||||
bb_error_msg("syntax error: unterminated %s", s);
|
bb_error_msg("syntax error: unterminated %s", s);
|
||||||
//? source4.tests fails: in bash, echo ${^} in script does not terminate the script
|
//? source4.tests fails: in bash, echo ${^} in script does not terminate the script
|
||||||
// die_if_script();
|
// die_if_script();
|
||||||
@ -2642,19 +2636,15 @@ static int get_user_input(struct in_str *i)
|
|||||||
);
|
);
|
||||||
/* read_line_input intercepts ^C, "convert" it to SIGINT */
|
/* read_line_input intercepts ^C, "convert" it to SIGINT */
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
G.flag_ctrlC = 1;
|
|
||||||
raise(SIGINT);
|
raise(SIGINT);
|
||||||
}
|
}
|
||||||
check_and_run_traps();
|
check_and_run_traps();
|
||||||
if (r != 0 && !G.flag_SIGINT)
|
if (r != 0 && !G.flag_SIGINT)
|
||||||
break;
|
break;
|
||||||
/* ^C or SIGINT: return EOF */
|
/* ^C or SIGINT: repeat */
|
||||||
/* bash prints ^C even on real SIGINT (non-kbd generated) */
|
/* bash prints ^C even on real SIGINT (non-kbd generated) */
|
||||||
write(STDOUT_FILENO, "^C\n", 3);
|
write(STDOUT_FILENO, "^C\n", 3);
|
||||||
G.last_exitcode = 128 | SIGINT;
|
G.last_exitcode = 128 | SIGINT;
|
||||||
i->p = NULL;
|
|
||||||
i->peek_buf[0] = r = EOF;
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
/* EOF/error detected */
|
/* EOF/error detected */
|
||||||
@ -5266,16 +5256,7 @@ static struct pipe *parse_stream(char **pstring,
|
|||||||
ch, ch, !!(ctx.word.o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
|
ch, ch, !!(ctx.word.o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
|
||||||
if (ch == EOF) {
|
if (ch == EOF) {
|
||||||
struct pipe *pi;
|
struct pipe *pi;
|
||||||
#if ENABLE_FEATURE_EDITING
|
|
||||||
if (G.flag_ctrlC) {
|
|
||||||
/* testcase: interactively entering
|
|
||||||
* 'qwe <cr> ^C
|
|
||||||
* should not leave input in PS2 mode, waiting to close single quote.
|
|
||||||
*/
|
|
||||||
G.flag_ctrlC = 0;
|
|
||||||
goto parse_error;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (heredoc_cnt) {
|
if (heredoc_cnt) {
|
||||||
syntax_error_unterm_str("here document");
|
syntax_error_unterm_str("here document");
|
||||||
goto parse_error_exitcode1;
|
goto parse_error_exitcode1;
|
||||||
|
Loading…
Reference in New Issue
Block a user