Hi, $ PS2='$(:)' $ cat <<EOF EOF Segmentation fault (core dumped)
diff --git a/eval.c b/eval.c index 1f65aac..d2b452d 100644 --- a/eval.c +++ b/eval.c @@ -52,6 +52,7 @@ extern int subshell_environment, running_under_emacs; extern int last_command_exit_value, stdin_redir; extern int need_here_doc; extern int current_command_number, current_command_line_count, line_number; +extern int last_command_line_count; extern int expand_aliases; #if defined (HAVE_POSIX_SIGNALS) @@ -234,6 +235,7 @@ parse_command () send_pwd_to_eterm (); /* Yuck */ } + last_command_line_count = current_command_line_count; current_command_line_count = 0; r = yyparse (); diff --git a/parse.y b/parse.y index 91bf3bf..d8ccd84 100644 --- a/parse.y +++ b/parse.y @@ -254,6 +254,8 @@ int current_command_line_count; /* The number of lines in a command saved while we run parse_and_execute */ int saved_command_line_count; +int last_command_line_count; + /* The token that currently denotes the end of parse. */ int shell_eof_token; @@ -2044,17 +2046,21 @@ char * read_secondary_line (remove_quoted_newline) int remove_quoted_newline; { + sh_parser_state_t ps; char *ret; int n, c; prompt_string_pointer = &ps2_prompt; - if (SHOULD_PROMPT()) + if (SHOULD_PROMPT()) { + save_parser_state (&ps); prompt_again (); + restore_parser_state (&ps); + } ret = read_a_line (remove_quoted_newline); #if defined (HISTORY) if (ret && remember_on_history && (parser_state & PST_HEREDOC)) { - /* To make adding the the here-document body right, we need to rely + /* To make adding 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. @@ -2639,7 +2645,7 @@ static int esacs_needed_count; void gather_here_documents () { - int r; + int save_need_here_doc, r; r = 0; while (need_here_doc) @@ -5117,6 +5123,7 @@ history_delimiting_chars (line) static void prompt_again () { + int saved_linecount, save_need_here_doc; char *temp_prompt; if (interactive == 0 || expanding_alias ()) /* XXX */ @@ -5128,10 +5135,17 @@ prompt_again () if (!prompt_string_pointer) prompt_string_pointer = &ps1_prompt; + save_need_here_doc = need_here_doc; + saved_linecount = current_command_line_count; + last_command_line_count = 0; + temp_prompt = *prompt_string_pointer ? decode_prompt_string (*prompt_string_pointer) : (char *)NULL; + need_here_doc = save_need_here_doc; + current_command_line_count = last_command_line_count + saved_linecount; + if (temp_prompt == 0) { temp_prompt = (char *)xmalloc (1);
pgpeMNay_fZT4.pgp
Description: PGP signature