diff options
| author | Chet Ramey <chet.ramey@case.edu> | 2022-08-26 11:08:51 -0400 |
|---|---|---|
| committer | Chet Ramey <chet.ramey@case.edu> | 2022-08-26 11:08:51 -0400 |
| commit | b3afafd86d27d61601cf380e1065d9170862fd10 (patch) | |
| tree | abaef1c96fadb1cbdab381dbe945b1373dbde51f /parse.y | |
| parent | f36c8c8ecd155104931198d898733bdb961bc27f (diff) | |
| download | bash-b3afafd86d27d61601cf380e1065d9170862fd10.tar.gz | |
Bash-5.2-rc3 releasebash-5.2-rc3
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 49 |
1 files changed, 42 insertions, 7 deletions
@@ -1666,7 +1666,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. */ @@ -3303,7 +3303,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 @@ -3328,6 +3328,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'; @@ -4098,6 +4103,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; @@ -4107,9 +4113,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 (); @@ -4120,11 +4130,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")); */ @@ -4135,13 +4154,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); } @@ -4226,6 +4258,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 */ @@ -4236,7 +4271,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); |
