diff options
Diffstat (limited to 'y.tab.c')
-rw-r--r-- | y.tab.c | 49 |
1 files changed, 42 insertions, 7 deletions
@@ -3977,7 +3977,7 @@ rewind_input_string () xchars++; /* XXX - how to reflect bash_input.location.string back to string passed to - parse_and_execute or xparse_dolparen? xparse_dolparen needs to know how + parse_and_execute or xparse_dolparen? xparse_dolparen needs to know how far into the string we parsed. parse_and_execute knows where bash_input. location.string is, and how far from orig_string that is -- that's the number of characters the command consumed. */ @@ -5614,7 +5614,7 @@ reset_parser () #if defined (EXTENDED_GLOB) /* Reset to global value of extended glob */ - if (parser_state & PST_EXTPAT) + if (parser_state & (PST_EXTPAT|PST_CMDSUBST)) extended_glob = global_extglob; #endif @@ -5639,6 +5639,11 @@ reset_parser () eol_ungetc_lookahead = 0; + /* added post-bash-5.1 */ + need_here_doc = 0; + redir_stack[0] = 0; + esacs_needed_count = expecting_in_token = 0; + current_token = '\n'; /* XXX */ last_read_token = '\n'; token_to_read = '\n'; @@ -6409,6 +6414,7 @@ parse_comsub (qc, open, close, lenp, flags) saved_global = global_command; /* might not be necessary */ global_command = (COMMAND *)NULL; + /* These are reset by reset_parser() */ need_here_doc = 0; esacs_needed_count = expecting_in_token = 0; @@ -6418,9 +6424,13 @@ parse_comsub (qc, open, close, lenp, flags) backwards compatibility. */ if (expand_aliases) expand_aliases = posixly_correct != 0; +#if defined (EXTENDED_GLOB) + global_extglob = extended_glob; + if (shell_compatibility_level <= 51) + extended_glob = 1; +#endif current_token = '\n'; /* XXX */ - token_to_read = DOLPAREN; /* let's trick the parser */ r = yyparse (); @@ -6431,11 +6441,20 @@ parse_comsub (qc, open, close, lenp, flags) gather_here_documents (); /* XXX check compatibility level? */ } +#if defined (EXTENDED_GLOB) + extended_glob = global_extglob; +#endif + parsed_command = global_command; if (EOF_Reached) - /* yyparse() has already called yyerror() */ - return (&matched_pair_error); + { + shell_eof_token = ps.eof_token; + expand_aliases = ps.expand_aliases; + + /* yyparse() has already called yyerror() and reset_parser() */ + return (&matched_pair_error); + } else if (r != 0) { /* parser_error (start_lineno, _("could not parse command substitution")); */ @@ -6446,13 +6465,26 @@ parse_comsub (qc, open, close, lenp, flags) if (interactive_shell == 0) jump_to_top_level (FORCE_EOF); /* This is like reader_loop() */ else - jump_to_top_level (DISCARD); + { + shell_eof_token = ps.eof_token; + expand_aliases = ps.expand_aliases; + + jump_to_top_level (DISCARD); + } } if (current_token != shell_eof_token) { INTERNAL_DEBUG(("current_token (%d) != shell_eof_token (%c)", current_token, shell_eof_token)); token_to_read = current_token; + + /* If we get here we can check eof_encountered and if it's 1 but the + previous EOF_Reached test didn't succeed, we can assume that the shell + is interactive and ignoreeof is set. We might want to restore the + parser state in this case. */ + shell_eof_token = ps.eof_token; + expand_aliases = ps.expand_aliases; + return (&matched_pair_error); } @@ -6537,6 +6569,9 @@ xparse_dolparen (base, string, indp, flags) command substitution and we want to defer it completely until then. The old value will be restored by restore_parser_state(). */ expand_aliases = 0; +#if defined (EXTENDED_GLOB) + global_extglob = extended_glob; +#endif token_to_read = DOLPAREN; /* let's trick the parser */ @@ -6547,7 +6582,7 @@ xparse_dolparen (base, string, indp, flags) if (current_token == shell_eof_token) yyclearin; /* might want to clear lookahead token unconditionally */ - reset_parser (); + reset_parser (); /* resets extended_glob too */ /* reset_parser() clears shell_input_line and associated variables, including parser_state, so we want to reset things, then restore what we need. */ restore_input_line_state (&ls); |