summaryrefslogtreecommitdiff
path: root/parse.y~
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2011-12-07 09:26:30 -0500
committerChet Ramey <chet.ramey@case.edu>2011-12-07 09:26:30 -0500
commit8e1a6eaa95d16cc9ec67523b9e9cb4a599ae4ace (patch)
tree607ef4058688250093e130daddac5f2278a77998 /parse.y~
parent547ef91456587b9d98629c56ff241799b5cae2d6 (diff)
downloadbash-8e1a6eaa95d16cc9ec67523b9e9cb4a599ae4ace.tar.gz
commit bash-20080724 snapshot
Diffstat (limited to 'parse.y~')
-rw-r--r--parse.y~42
1 files changed, 37 insertions, 5 deletions
diff --git a/parse.y~ b/parse.y~
index 537f81e7..83446771 100644
--- a/parse.y~
+++ b/parse.y~
@@ -1867,10 +1867,25 @@ char *
read_secondary_line (remove_quoted_newline)
int remove_quoted_newline;
{
+ char *ret;
+ int n, c;
+
prompt_string_pointer = &ps2_prompt;
if (SHOULD_PROMPT())
prompt_again ();
- return (read_a_line (remove_quoted_newline));
+ ret = read_a_line (remove_quoted_newline);
+ if (remember_on_history && (parser_state & PST_HEREDOC))
+ {
+ /* To make adding the the here-document body right, we need to rely
+ on history_delimiting_chars() returning \n for the first line of
+ the here-document body and the null string for the second and
+ subsequent lines, so we avoid double newlines.
+ current_command_line_count == 2 for the first line of the body. */
+
+ current_command_line_count++;
+ maybe_add_history (ret);
+ }
+ return ret;
}
/* **************************************************************** */
@@ -2342,7 +2357,6 @@ yylex ()
if ((parser_state & PST_EOFTOKEN) && current_token == shell_eof_token)
{
-itrace("shell_eof_token == ')'; setting current_token == yacc_EOF");
current_token = yacc_EOF;
if (bash_input.type == st_string)
rewind_input_string ();
@@ -2359,10 +2373,14 @@ static int esacs_needed_count;
void
gather_here_documents ()
{
- int r = 0;
+ int r;
+
+ r = 0;
while (need_here_doc)
{
+ parser_state |= PST_HEREDOC;
make_here_document (redir_stack[r++], line_number);
+ parser_state &= ~PST_HEREDOC;
need_here_doc--;
}
}
@@ -2940,7 +2958,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
char *ret, *nestret, *ttrans;
int retind, retsize, rflags;
-/* itrace("parse_matched_pair: open = %c close = %c", open, close); */
+/* itrace("parse_matched_pair: open = %c close = %c flags = %d", open, close, flags); */
count = 1;
tflags = 0;
@@ -3039,6 +3057,14 @@ parse_matched_pair (qc, open, close, lenp, flags)
if MBTEST(ch == '\\') /* backslashes */
tflags |= LEX_PASSNEXT;
+#if 0
+ /* The big hammer. Single quotes aren't special in double quotes, even
+ double-quoted parameter expansions. XXX - do the same thing for
+ command substitution/arithmetic expansion? */
+ if MBTEST(open == '{' && (flags & P_DQUOTE) && ch == '\'') /* } */
+ continue;
+#endif
+
/* Could also check open == '`' if we want to parse grouping constructs
inside old-style command substitution. */
if (open != close) /* a grouping construct */
@@ -4500,7 +4526,13 @@ history_delimiting_chars ()
if (dstack.delimiter_depth != 0)
return ("\n");
-
+
+ /* We look for current_command_line_count == 2 because we are looking to
+ add the first line of the body of the here document (the second line
+ of the command). */
+ if (parser_state & PST_HEREDOC)
+ return (current_command_line_count == 2 ? "\n" : "");
+
/* First, handle some special cases. */
/*(*/
/* If we just read `()', assume it's a function definition, and don't