Imported from ../bash-3.2.48.tar.gz.
[platform/upstream/bash.git] / y.tab.c
diff --git a/y.tab.c b/y.tab.c
index bff19c4..f8db50d 100644 (file)
--- a/y.tab.c
+++ b/y.tab.c
@@ -78,6 +78,7 @@
 #include "parser.h"
 #include "mailcheck.h"
 #include "test.h"
+#include "builtins.h"
 #include "builtins/common.h"
 #include "builtins/builtext.h"
 
@@ -145,7 +146,6 @@ extern int current_command_number;
 extern int sourcelevel;
 extern int posixly_correct;
 extern int last_command_exit_value;
-extern int interrupt_immediately;
 extern char *shell_name, *current_host_name;
 extern char *dist_version;
 extern int patch_level;
@@ -233,10 +233,6 @@ static void reset_readline_prompt __P((void));
 #endif
 static void print_prompt __P((void));
 
-#if defined (HISTORY)
-char *history_delimiting_chars __P((void));
-#endif
-
 #if defined (HANDLE_MULTIBYTE)
 static void set_line_mbstate __P((void));
 static char *shell_input_line_property = NULL;
@@ -323,7 +319,7 @@ static WORD_DESC *word_desc_to_read;
 
 static REDIRECTEE redir;
 
-#line 299 "/Users/chet/src/bash/src/parse.y"
+#line 295 "/Users/chet/src/bash/src/parse.y"
 typedef union {
   WORD_DESC *word;             /* the word that we read. */
   int number;                  /* the number that we read. */
@@ -465,20 +461,20 @@ static const short yyrhs[] = {    85,
 
 #if YYDEBUG != 0
 static const short yyrline[] = { 0,
-   350,   359,   366,   381,   391,   393,   397,   402,   407,   412,
-   417,   422,   427,   433,   439,   444,   449,   454,   459,   464,
-   469,   474,   479,   484,   489,   496,   503,   508,   513,   518,
-   523,   528,   533,   538,   543,   550,   552,   554,   558,   562,
-   573,   575,   579,   581,   583,   599,   603,   605,   607,   609,
-   611,   613,   615,   617,   619,   621,   623,   627,   632,   637,
-   642,   647,   652,   657,   662,   669,   674,   679,   684,   691,
-   696,   701,   706,   711,   716,   723,   728,   733,   740,   743,
-   746,   751,   753,   784,   791,   793,   795,   800,   804,   808,
-   812,   814,   816,   820,   821,   825,   827,   829,   831,   835,
-   836,   840,   842,   851,   859,   860,   866,   867,   874,   878,
-   880,   882,   889,   891,   893,   897,   898,   901,   903,   905,
-   909,   910,   919,   925,   934,   942,   944,   946,   953,   956,
-   960,   962,   967,   972,   977,   982,  1002,  1005,  1009,  1011
+   346,   355,   362,   377,   387,   389,   393,   398,   403,   408,
+   413,   418,   423,   429,   435,   440,   445,   450,   455,   460,
+   465,   470,   475,   480,   485,   492,   499,   504,   509,   514,
+   519,   524,   529,   534,   539,   546,   548,   550,   554,   558,
+   569,   571,   575,   577,   579,   595,   599,   601,   603,   605,
+   607,   609,   611,   613,   615,   617,   619,   623,   628,   633,
+   638,   643,   648,   653,   658,   665,   670,   675,   680,   687,
+   692,   697,   702,   707,   712,   719,   724,   729,   736,   739,
+   742,   747,   749,   780,   787,   789,   791,   796,   800,   804,
+   808,   810,   812,   816,   817,   821,   823,   825,   827,   831,
+   832,   836,   838,   847,   855,   856,   862,   863,   870,   874,
+   876,   878,   885,   887,   889,   893,   894,   897,   899,   901,
+   905,   906,   915,   921,   930,   938,   940,   942,   949,   952,
+   956,   958,   964,   970,   976,   982,  1002,  1005,  1009,  1011
 };
 #endif
 
@@ -1292,7 +1288,7 @@ yyreduce:
   switch (yyn) {
 
 case 1:
-#line 351 "/Users/chet/src/bash/src/parse.y"
+#line 347 "/Users/chet/src/bash/src/parse.y"
 {
                          /* Case of regular command.  Discard the error
                             safety net,and return the command just parsed. */
@@ -1303,7 +1299,7 @@ case 1:
                        ;
     break;}
 case 2:
-#line 360 "/Users/chet/src/bash/src/parse.y"
+#line 356 "/Users/chet/src/bash/src/parse.y"
 {
                          /* Case of regular command, but not a very
                             interesting one.  Return a NULL command. */
@@ -1312,7 +1308,7 @@ case 2:
                        ;
     break;}
 case 3:
-#line 367 "/Users/chet/src/bash/src/parse.y"
+#line 363 "/Users/chet/src/bash/src/parse.y"
 {
                          /* Error during parsing.  Return NULL command. */
                          global_command = (COMMAND *)NULL;
@@ -1329,7 +1325,7 @@ case 3:
                        ;
     break;}
 case 4:
-#line 382 "/Users/chet/src/bash/src/parse.y"
+#line 378 "/Users/chet/src/bash/src/parse.y"
 {
                          /* Case of EOF seen by itself.  Do ignoreeof or
                             not. */
@@ -1339,57 +1335,57 @@ case 4:
                        ;
     break;}
 case 5:
-#line 392 "/Users/chet/src/bash/src/parse.y"
+#line 388 "/Users/chet/src/bash/src/parse.y"
 { yyval.word_list = make_word_list (yyvsp[0].word, (WORD_LIST *)NULL); ;
     break;}
 case 6:
-#line 394 "/Users/chet/src/bash/src/parse.y"
+#line 390 "/Users/chet/src/bash/src/parse.y"
 { yyval.word_list = make_word_list (yyvsp[0].word, yyvsp[-1].word_list); ;
     break;}
 case 7:
-#line 398 "/Users/chet/src/bash/src/parse.y"
+#line 394 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (1, r_output_direction, redir);
                        ;
     break;}
 case 8:
-#line 403 "/Users/chet/src/bash/src/parse.y"
+#line 399 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (0, r_input_direction, redir);
                        ;
     break;}
 case 9:
-#line 408 "/Users/chet/src/bash/src/parse.y"
+#line 404 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_output_direction, redir);
                        ;
     break;}
 case 10:
-#line 413 "/Users/chet/src/bash/src/parse.y"
+#line 409 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_input_direction, redir);
                        ;
     break;}
 case 11:
-#line 418 "/Users/chet/src/bash/src/parse.y"
+#line 414 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (1, r_appending_to, redir);
                        ;
     break;}
 case 12:
-#line 423 "/Users/chet/src/bash/src/parse.y"
+#line 419 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_appending_to, redir);
                        ;
     break;}
 case 13:
-#line 428 "/Users/chet/src/bash/src/parse.y"
+#line 424 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (0, r_reading_until, redir);
@@ -1397,7 +1393,7 @@ case 13:
                        ;
     break;}
 case 14:
-#line 434 "/Users/chet/src/bash/src/parse.y"
+#line 430 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_reading_until, redir);
@@ -1405,77 +1401,77 @@ case 14:
                        ;
     break;}
 case 15:
-#line 440 "/Users/chet/src/bash/src/parse.y"
+#line 436 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (0, r_reading_string, redir);
                        ;
     break;}
 case 16:
-#line 445 "/Users/chet/src/bash/src/parse.y"
+#line 441 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_reading_string, redir);
                        ;
     break;}
 case 17:
-#line 450 "/Users/chet/src/bash/src/parse.y"
+#line 446 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = yyvsp[0].number;
                          yyval.redirect = make_redirection (0, r_duplicating_input, redir);
                        ;
     break;}
 case 18:
-#line 455 "/Users/chet/src/bash/src/parse.y"
+#line 451 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = yyvsp[0].number;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_input, redir);
                        ;
     break;}
 case 19:
-#line 460 "/Users/chet/src/bash/src/parse.y"
+#line 456 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = yyvsp[0].number;
                          yyval.redirect = make_redirection (1, r_duplicating_output, redir);
                        ;
     break;}
 case 20:
-#line 465 "/Users/chet/src/bash/src/parse.y"
+#line 461 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = yyvsp[0].number;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_output, redir);
                        ;
     break;}
 case 21:
-#line 470 "/Users/chet/src/bash/src/parse.y"
+#line 466 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (0, r_duplicating_input_word, redir);
                        ;
     break;}
 case 22:
-#line 475 "/Users/chet/src/bash/src/parse.y"
+#line 471 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_input_word, redir);
                        ;
     break;}
 case 23:
-#line 480 "/Users/chet/src/bash/src/parse.y"
+#line 476 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (1, r_duplicating_output_word, redir);
                        ;
     break;}
 case 24:
-#line 485 "/Users/chet/src/bash/src/parse.y"
+#line 481 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_duplicating_output_word, redir);
                        ;
     break;}
 case 25:
-#line 490 "/Users/chet/src/bash/src/parse.y"
+#line 486 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection
@@ -1484,7 +1480,7 @@ case 25:
                        ;
     break;}
 case 26:
-#line 497 "/Users/chet/src/bash/src/parse.y"
+#line 493 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection
@@ -1493,88 +1489,88 @@ case 26:
                        ;
     break;}
 case 27:
-#line 504 "/Users/chet/src/bash/src/parse.y"
+#line 500 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = 0;
                          yyval.redirect = make_redirection (1, r_close_this, redir);
                        ;
     break;}
 case 28:
-#line 509 "/Users/chet/src/bash/src/parse.y"
+#line 505 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = 0;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_close_this, redir);
                        ;
     break;}
 case 29:
-#line 514 "/Users/chet/src/bash/src/parse.y"
+#line 510 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = 0;
                          yyval.redirect = make_redirection (0, r_close_this, redir);
                        ;
     break;}
 case 30:
-#line 519 "/Users/chet/src/bash/src/parse.y"
+#line 515 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.dest = 0;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_close_this, redir);
                        ;
     break;}
 case 31:
-#line 524 "/Users/chet/src/bash/src/parse.y"
+#line 520 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (1, r_err_and_out, redir);
                        ;
     break;}
 case 32:
-#line 529 "/Users/chet/src/bash/src/parse.y"
+#line 525 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_input_output, redir);
                        ;
     break;}
 case 33:
-#line 534 "/Users/chet/src/bash/src/parse.y"
+#line 530 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (0, r_input_output, redir);
                        ;
     break;}
 case 34:
-#line 539 "/Users/chet/src/bash/src/parse.y"
+#line 535 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (1, r_output_force, redir);
                        ;
     break;}
 case 35:
-#line 544 "/Users/chet/src/bash/src/parse.y"
+#line 540 "/Users/chet/src/bash/src/parse.y"
 {
                          redir.filename = yyvsp[0].word;
                          yyval.redirect = make_redirection (yyvsp[-2].number, r_output_force, redir);
                        ;
     break;}
 case 36:
-#line 551 "/Users/chet/src/bash/src/parse.y"
+#line 547 "/Users/chet/src/bash/src/parse.y"
 { yyval.element.word = yyvsp[0].word; yyval.element.redirect = 0; ;
     break;}
 case 37:
-#line 553 "/Users/chet/src/bash/src/parse.y"
+#line 549 "/Users/chet/src/bash/src/parse.y"
 { yyval.element.word = yyvsp[0].word; yyval.element.redirect = 0; ;
     break;}
 case 38:
-#line 555 "/Users/chet/src/bash/src/parse.y"
+#line 551 "/Users/chet/src/bash/src/parse.y"
 { yyval.element.redirect = yyvsp[0].redirect; yyval.element.word = 0; ;
     break;}
 case 39:
-#line 559 "/Users/chet/src/bash/src/parse.y"
+#line 555 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.redirect = yyvsp[0].redirect;
                        ;
     break;}
 case 40:
-#line 563 "/Users/chet/src/bash/src/parse.y"
+#line 559 "/Users/chet/src/bash/src/parse.y"
 {
                          register REDIRECT *t;
 
@@ -1585,23 +1581,23 @@ case 40:
                        ;
     break;}
 case 41:
-#line 574 "/Users/chet/src/bash/src/parse.y"
+#line 570 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_simple_command (yyvsp[0].element, (COMMAND *)NULL); ;
     break;}
 case 42:
-#line 576 "/Users/chet/src/bash/src/parse.y"
+#line 572 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_simple_command (yyvsp[0].element, yyvsp[-1].command); ;
     break;}
 case 43:
-#line 580 "/Users/chet/src/bash/src/parse.y"
+#line 576 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = clean_simple_command (yyvsp[0].command); ;
     break;}
 case 44:
-#line 582 "/Users/chet/src/bash/src/parse.y"
+#line 578 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 45:
-#line 584 "/Users/chet/src/bash/src/parse.y"
+#line 580 "/Users/chet/src/bash/src/parse.y"
 {
                          COMMAND *tc;
 
@@ -1619,218 +1615,218 @@ case 45:
                        ;
     break;}
 case 46:
-#line 600 "/Users/chet/src/bash/src/parse.y"
+#line 596 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 47:
-#line 604 "/Users/chet/src/bash/src/parse.y"
+#line 600 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 48:
-#line 606 "/Users/chet/src/bash/src/parse.y"
+#line 602 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 49:
-#line 608 "/Users/chet/src/bash/src/parse.y"
+#line 604 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_while_command (yyvsp[-3].command, yyvsp[-1].command); ;
     break;}
 case 50:
-#line 610 "/Users/chet/src/bash/src/parse.y"
+#line 606 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_until_command (yyvsp[-3].command, yyvsp[-1].command); ;
     break;}
 case 51:
-#line 612 "/Users/chet/src/bash/src/parse.y"
+#line 608 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 52:
-#line 614 "/Users/chet/src/bash/src/parse.y"
+#line 610 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 53:
-#line 616 "/Users/chet/src/bash/src/parse.y"
+#line 612 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 54:
-#line 618 "/Users/chet/src/bash/src/parse.y"
+#line 614 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 55:
-#line 620 "/Users/chet/src/bash/src/parse.y"
+#line 616 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 56:
-#line 622 "/Users/chet/src/bash/src/parse.y"
+#line 618 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 57:
-#line 624 "/Users/chet/src/bash/src/parse.y"
+#line 620 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 58:
-#line 628 "/Users/chet/src/bash/src/parse.y"
+#line 624 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 59:
-#line 633 "/Users/chet/src/bash/src/parse.y"
+#line 629 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 60:
-#line 638 "/Users/chet/src/bash/src/parse.y"
+#line 634 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 61:
-#line 643 "/Users/chet/src/bash/src/parse.y"
+#line 639 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 62:
-#line 648 "/Users/chet/src/bash/src/parse.y"
+#line 644 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 63:
-#line 653 "/Users/chet/src/bash/src/parse.y"
+#line 649 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 64:
-#line 658 "/Users/chet/src/bash/src/parse.y"
+#line 654 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-7].word, (WORD_LIST *)NULL, yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 65:
-#line 663 "/Users/chet/src/bash/src/parse.y"
+#line 659 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_for_command (yyvsp[-7].word, (WORD_LIST *)NULL, yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 66:
-#line 670 "/Users/chet/src/bash/src/parse.y"
+#line 666 "/Users/chet/src/bash/src/parse.y"
 {
                                  yyval.command = make_arith_for_command (yyvsp[-5].word_list, yyvsp[-1].command, arith_for_lineno);
                                  if (word_top > 0) word_top--;
                                ;
     break;}
 case 67:
-#line 675 "/Users/chet/src/bash/src/parse.y"
+#line 671 "/Users/chet/src/bash/src/parse.y"
 {
                                  yyval.command = make_arith_for_command (yyvsp[-5].word_list, yyvsp[-1].command, arith_for_lineno);
                                  if (word_top > 0) word_top--;
                                ;
     break;}
 case 68:
-#line 680 "/Users/chet/src/bash/src/parse.y"
+#line 676 "/Users/chet/src/bash/src/parse.y"
 {
                                  yyval.command = make_arith_for_command (yyvsp[-3].word_list, yyvsp[-1].command, arith_for_lineno);
                                  if (word_top > 0) word_top--;
                                ;
     break;}
 case 69:
-#line 685 "/Users/chet/src/bash/src/parse.y"
+#line 681 "/Users/chet/src/bash/src/parse.y"
 {
                                  yyval.command = make_arith_for_command (yyvsp[-3].word_list, yyvsp[-1].command, arith_for_lineno);
                                  if (word_top > 0) word_top--;
                                ;
     break;}
 case 70:
-#line 692 "/Users/chet/src/bash/src/parse.y"
+#line 688 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_select_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 71:
-#line 697 "/Users/chet/src/bash/src/parse.y"
+#line 693 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_select_command (yyvsp[-4].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 72:
-#line 702 "/Users/chet/src/bash/src/parse.y"
+#line 698 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_select_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 73:
-#line 707 "/Users/chet/src/bash/src/parse.y"
+#line 703 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_select_command (yyvsp[-5].word, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 74:
-#line 712 "/Users/chet/src/bash/src/parse.y"
+#line 708 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_select_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 75:
-#line 717 "/Users/chet/src/bash/src/parse.y"
+#line 713 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_select_command (yyvsp[-8].word, REVERSE_LIST (yyvsp[-5].word_list, WORD_LIST *), yyvsp[-1].command, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 76:
-#line 724 "/Users/chet/src/bash/src/parse.y"
+#line 720 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_case_command (yyvsp[-4].word, (PATTERN_LIST *)NULL, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 77:
-#line 729 "/Users/chet/src/bash/src/parse.y"
+#line 725 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_case_command (yyvsp[-5].word, yyvsp[-2].pattern, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 78:
-#line 734 "/Users/chet/src/bash/src/parse.y"
+#line 730 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_case_command (yyvsp[-4].word, yyvsp[-1].pattern, word_lineno[word_top]);
                          if (word_top > 0) word_top--;
                        ;
     break;}
 case 79:
-#line 741 "/Users/chet/src/bash/src/parse.y"
+#line 737 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_function_def (yyvsp[-4].word, yyvsp[0].command, function_dstart, function_bstart); ;
     break;}
 case 80:
-#line 744 "/Users/chet/src/bash/src/parse.y"
+#line 740 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_function_def (yyvsp[-4].word, yyvsp[0].command, function_dstart, function_bstart); ;
     break;}
 case 81:
-#line 747 "/Users/chet/src/bash/src/parse.y"
+#line 743 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_function_def (yyvsp[-2].word, yyvsp[0].command, function_dstart, function_bstart); ;
     break;}
 case 82:
-#line 752 "/Users/chet/src/bash/src/parse.y"
+#line 748 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 83:
-#line 754 "/Users/chet/src/bash/src/parse.y"
+#line 750 "/Users/chet/src/bash/src/parse.y"
 {
                          COMMAND *tc;
 
@@ -1861,82 +1857,82 @@ case 83:
                        ;
     break;}
 case 84:
-#line 785 "/Users/chet/src/bash/src/parse.y"
+#line 781 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = make_subshell_command (yyvsp[-1].command);
                          yyval.command->flags |= CMD_WANT_SUBSHELL;
                        ;
     break;}
 case 85:
-#line 792 "/Users/chet/src/bash/src/parse.y"
+#line 788 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_if_command (yyvsp[-3].command, yyvsp[-1].command, (COMMAND *)NULL); ;
     break;}
 case 86:
-#line 794 "/Users/chet/src/bash/src/parse.y"
+#line 790 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_if_command (yyvsp[-5].command, yyvsp[-3].command, yyvsp[-1].command); ;
     break;}
 case 87:
-#line 796 "/Users/chet/src/bash/src/parse.y"
+#line 792 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_if_command (yyvsp[-4].command, yyvsp[-2].command, yyvsp[-1].command); ;
     break;}
 case 88:
-#line 801 "/Users/chet/src/bash/src/parse.y"
+#line 797 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_group_command (yyvsp[-1].command); ;
     break;}
 case 89:
-#line 805 "/Users/chet/src/bash/src/parse.y"
+#line 801 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_arith_command (yyvsp[0].word_list); ;
     break;}
 case 90:
-#line 809 "/Users/chet/src/bash/src/parse.y"
+#line 805 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[-1].command; ;
     break;}
 case 91:
-#line 813 "/Users/chet/src/bash/src/parse.y"
+#line 809 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_if_command (yyvsp[-2].command, yyvsp[0].command, (COMMAND *)NULL); ;
     break;}
 case 92:
-#line 815 "/Users/chet/src/bash/src/parse.y"
+#line 811 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_if_command (yyvsp[-4].command, yyvsp[-2].command, yyvsp[0].command); ;
     break;}
 case 93:
-#line 817 "/Users/chet/src/bash/src/parse.y"
+#line 813 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = make_if_command (yyvsp[-3].command, yyvsp[-1].command, yyvsp[0].command); ;
     break;}
 case 95:
-#line 822 "/Users/chet/src/bash/src/parse.y"
+#line 818 "/Users/chet/src/bash/src/parse.y"
 { yyvsp[0].pattern->next = yyvsp[-1].pattern; yyval.pattern = yyvsp[0].pattern; ;
     break;}
 case 96:
-#line 826 "/Users/chet/src/bash/src/parse.y"
+#line 822 "/Users/chet/src/bash/src/parse.y"
 { yyval.pattern = make_pattern_list (yyvsp[-2].word_list, yyvsp[0].command); ;
     break;}
 case 97:
-#line 828 "/Users/chet/src/bash/src/parse.y"
+#line 824 "/Users/chet/src/bash/src/parse.y"
 { yyval.pattern = make_pattern_list (yyvsp[-2].word_list, (COMMAND *)NULL); ;
     break;}
 case 98:
-#line 830 "/Users/chet/src/bash/src/parse.y"
+#line 826 "/Users/chet/src/bash/src/parse.y"
 { yyval.pattern = make_pattern_list (yyvsp[-2].word_list, yyvsp[0].command); ;
     break;}
 case 99:
-#line 832 "/Users/chet/src/bash/src/parse.y"
+#line 828 "/Users/chet/src/bash/src/parse.y"
 { yyval.pattern = make_pattern_list (yyvsp[-2].word_list, (COMMAND *)NULL); ;
     break;}
 case 101:
-#line 837 "/Users/chet/src/bash/src/parse.y"
+#line 833 "/Users/chet/src/bash/src/parse.y"
 { yyvsp[-1].pattern->next = yyvsp[-2].pattern; yyval.pattern = yyvsp[-1].pattern; ;
     break;}
 case 102:
-#line 841 "/Users/chet/src/bash/src/parse.y"
+#line 837 "/Users/chet/src/bash/src/parse.y"
 { yyval.word_list = make_word_list (yyvsp[0].word, (WORD_LIST *)NULL); ;
     break;}
 case 103:
-#line 843 "/Users/chet/src/bash/src/parse.y"
+#line 839 "/Users/chet/src/bash/src/parse.y"
 { yyval.word_list = make_word_list (yyvsp[0].word, yyvsp[-2].word_list); ;
     break;}
 case 104:
-#line 852 "/Users/chet/src/bash/src/parse.y"
+#line 848 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = yyvsp[0].command;
                          if (need_here_doc)
@@ -1944,13 +1940,13 @@ case 104:
                         ;
     break;}
 case 106:
-#line 861 "/Users/chet/src/bash/src/parse.y"
+#line 857 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = yyvsp[0].command;
                        ;
     break;}
 case 108:
-#line 868 "/Users/chet/src/bash/src/parse.y"
+#line 864 "/Users/chet/src/bash/src/parse.y"
 {
                          if (yyvsp[-2].command->type == cm_connection)
                            yyval.command = connect_async_list (yyvsp[-2].command, (COMMAND *)NULL, '&');
@@ -1959,15 +1955,15 @@ case 108:
                        ;
     break;}
 case 110:
-#line 879 "/Users/chet/src/bash/src/parse.y"
+#line 875 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, AND_AND); ;
     break;}
 case 111:
-#line 881 "/Users/chet/src/bash/src/parse.y"
+#line 877 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, OR_OR); ;
     break;}
 case 112:
-#line 883 "/Users/chet/src/bash/src/parse.y"
+#line 879 "/Users/chet/src/bash/src/parse.y"
 {
                          if (yyvsp[-3].command->type == cm_connection)
                            yyval.command = connect_async_list (yyvsp[-3].command, yyvsp[0].command, '&');
@@ -1976,31 +1972,31 @@ case 112:
                        ;
     break;}
 case 113:
-#line 890 "/Users/chet/src/bash/src/parse.y"
+#line 886 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, ';'); ;
     break;}
 case 114:
-#line 892 "/Users/chet/src/bash/src/parse.y"
+#line 888 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, ';'); ;
     break;}
 case 115:
-#line 894 "/Users/chet/src/bash/src/parse.y"
+#line 890 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 118:
-#line 902 "/Users/chet/src/bash/src/parse.y"
+#line 898 "/Users/chet/src/bash/src/parse.y"
 { yyval.number = '\n'; ;
     break;}
 case 119:
-#line 904 "/Users/chet/src/bash/src/parse.y"
+#line 900 "/Users/chet/src/bash/src/parse.y"
 { yyval.number = ';'; ;
     break;}
 case 120:
-#line 906 "/Users/chet/src/bash/src/parse.y"
+#line 902 "/Users/chet/src/bash/src/parse.y"
 { yyval.number = yacc_EOF; ;
     break;}
 case 123:
-#line 920 "/Users/chet/src/bash/src/parse.y"
+#line 916 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = yyvsp[0].command;
                          if (need_here_doc)
@@ -2008,7 +2004,7 @@ case 123:
                        ;
     break;}
 case 124:
-#line 926 "/Users/chet/src/bash/src/parse.y"
+#line 922 "/Users/chet/src/bash/src/parse.y"
 {
                          if (yyvsp[-1].command->type == cm_connection)
                            yyval.command = connect_async_list (yyvsp[-1].command, (COMMAND *)NULL, '&');
@@ -2019,7 +2015,7 @@ case 124:
                        ;
     break;}
 case 125:
-#line 935 "/Users/chet/src/bash/src/parse.y"
+#line 931 "/Users/chet/src/bash/src/parse.y"
 {
                          yyval.command = yyvsp[-1].command;
                          if (need_here_doc)
@@ -2027,15 +2023,15 @@ case 125:
                        ;
     break;}
 case 126:
-#line 943 "/Users/chet/src/bash/src/parse.y"
+#line 939 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, AND_AND); ;
     break;}
 case 127:
-#line 945 "/Users/chet/src/bash/src/parse.y"
+#line 941 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-3].command, yyvsp[0].command, OR_OR); ;
     break;}
 case 128:
-#line 947 "/Users/chet/src/bash/src/parse.y"
+#line 943 "/Users/chet/src/bash/src/parse.y"
 {
                          if (yyvsp[-2].command->type == cm_connection)
                            yyval.command = connect_async_list (yyvsp[-2].command, yyvsp[0].command, '&');
@@ -2044,42 +2040,46 @@ case 128:
                        ;
     break;}
 case 129:
-#line 954 "/Users/chet/src/bash/src/parse.y"
+#line 950 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = command_connect (yyvsp[-2].command, yyvsp[0].command, ';'); ;
     break;}
 case 130:
-#line 957 "/Users/chet/src/bash/src/parse.y"
+#line 953 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 131:
-#line 961 "/Users/chet/src/bash/src/parse.y"
+#line 957 "/Users/chet/src/bash/src/parse.y"
 { yyval.command = yyvsp[0].command; ;
     break;}
 case 132:
-#line 963 "/Users/chet/src/bash/src/parse.y"
+#line 959 "/Users/chet/src/bash/src/parse.y"
 {
-                         yyvsp[0].command->flags |= CMD_INVERT_RETURN;
+                         if (yyvsp[0].command)
+                           yyvsp[0].command->flags |= CMD_INVERT_RETURN;
                          yyval.command = yyvsp[0].command;
                        ;
     break;}
 case 133:
-#line 968 "/Users/chet/src/bash/src/parse.y"
+#line 965 "/Users/chet/src/bash/src/parse.y"
 {
-                         yyvsp[0].command->flags |= yyvsp[-1].number;
+                         if (yyvsp[0].command)
+                           yyvsp[0].command->flags |= yyvsp[-1].number;
                          yyval.command = yyvsp[0].command;
                        ;
     break;}
 case 134:
-#line 973 "/Users/chet/src/bash/src/parse.y"
+#line 971 "/Users/chet/src/bash/src/parse.y"
 {
-                         yyvsp[0].command->flags |= yyvsp[-2].number|CMD_INVERT_RETURN;
+                         if (yyvsp[0].command)
+                           yyvsp[0].command->flags |= yyvsp[-2].number|CMD_INVERT_RETURN;
                          yyval.command = yyvsp[0].command;
                        ;
     break;}
 case 135:
-#line 978 "/Users/chet/src/bash/src/parse.y"
+#line 977 "/Users/chet/src/bash/src/parse.y"
 {
-                         yyvsp[0].command->flags |= yyvsp[-1].number|CMD_INVERT_RETURN;
+                         if (yyvsp[0].command)
+                           yyvsp[0].command->flags |= yyvsp[-1].number|CMD_INVERT_RETURN;
                          yyval.command = yyvsp[0].command;
                        ;
     break;}
@@ -2358,6 +2358,7 @@ yyerrhandle:
 #define PST_ALEXPAND   0x0800          /* OK to expand aliases - unused */
 #define PST_CMDTOKEN   0x1000          /* command token OK - unused */
 #define PST_COMPASSIGN 0x2000          /* parsing x=(...) compound assignment */
+#define PST_ASSIGNOK   0x4000          /* assignment statement ok in this context */
 
 /* Initial size to allocate for tokens, and the
    amount to grow them by. */
@@ -2536,10 +2537,12 @@ yy_readline_get ()
          old_sigint = (SigHandler *)set_signal_handler (SIGINT, sigint_sighandler);
          interrupt_immediately++;
        }
+      terminate_immediately = 1;
 
       current_readline_line = readline (current_readline_prompt ?
                                          current_readline_prompt : "");
 
+      terminate_immediately = 0;
       if (signal_is_ignored (SIGINT) == 0 && old_sigint)
        {
          interrupt_immediately--;
@@ -2669,8 +2672,19 @@ yy_stream_get ()
 
   result = EOF;
   if (bash_input.location.file)
-    result = getc_with_restart (bash_input.location.file);
-
+    {
+      if (interactive)
+       {
+         interrupt_immediately++;
+         terminate_immediately++;
+       }
+      result = getc_with_restart (bash_input.location.file);
+      if (interactive)
+       {
+         interrupt_immediately--;
+         terminate_immediately--;
+       }
+    }
   return (result);
 }
 
@@ -2983,11 +2997,11 @@ read_a_line (remove_quoted_newline)
   pass_next = 0;
   while (1)
     {
-      c = yy_getc ();
-
       /* Allow immediate exit if interrupted during input. */
       QUIT;
 
+      c = yy_getc ();
+
       /* Ignore null bytes in input. */
       if (c == 0)
        {
@@ -3188,10 +3202,15 @@ shell_getc (remove_quoted_newline)
   register int i;
   int c;
   unsigned char uc;
-  static int mustpop = 0;
 
   QUIT;
 
+  if (sigwinch_received)
+    {
+      sigwinch_received = 0;
+      get_new_window_size (0, (int *)0, (int *)0);
+    }
+      
   if (eol_ungetc_lookahead)
     {
       c = eol_ungetc_lookahead;
@@ -3385,14 +3404,6 @@ shell_getc (remove_quoted_newline)
   if (uc)
     shell_input_line_index++;
 
-  if MBTEST(uc == '\\' && remove_quoted_newline && shell_input_line[shell_input_line_index] == '\n')
-    {
-       if (SHOULD_PROMPT ())
-         prompt_again ();
-       line_number++;
-       goto restart_read;
-    }
-
 #if defined (ALIAS) || defined (DPAREN_ARITHMETIC)
   /* If UC is NULL, we have reached the end of the current input string.  If
      pushed_string_list is non-empty, it's time to pop to the previous string
@@ -3408,6 +3419,14 @@ shell_getc (remove_quoted_newline)
     }
 #endif /* ALIAS || DPAREN_ARITHMETIC */
 
+  if MBTEST(uc == '\\' && remove_quoted_newline && shell_input_line[shell_input_line_index] == '\n')
+    {
+       if (SHOULD_PROMPT ())
+         prompt_again ();
+       line_number++;
+       goto restart_read;
+    }
+
   if (!uc && shell_input_line_terminator == EOF)
     return ((shell_input_line_index != 0) ? '\n' : EOF);
 
@@ -3455,8 +3474,8 @@ discard_until (character)
 }
 
 void
-execute_prompt_command (command)
-     char *command;
+execute_variable_command (command, vname)
+     char *command, *vname;
 {
   char *last_lastarg;
   sh_parser_state_t ps;
@@ -3466,10 +3485,10 @@ execute_prompt_command (command)
   if (last_lastarg)
     last_lastarg = savestring (last_lastarg);
 
-  parse_and_execute (savestring (command), "PROMPT_COMMAND", SEVAL_NONINT|SEVAL_NOHIST);
+  parse_and_execute (savestring (command), vname, SEVAL_NONINT|SEVAL_NOHIST);
 
   restore_parser_state (&ps);
-  bind_variable ("_", last_lastarg);
+  bind_variable ("_", last_lastarg, 0);
   FREE (last_lastarg);
 
   if (token_to_read == '\n')   /* reset_parser was called */
@@ -3869,7 +3888,7 @@ read_token (command)
 #endif /* ALIAS */
 
   /* Read a single word from input.  Start by skipping blanks. */
-  while ((character = shell_getc (1)) != EOF && whitespace (character))
+  while ((character = shell_getc (1)) != EOF && shellblank (character))
     ;
 
   if (character == EOF)
@@ -3897,6 +3916,8 @@ read_token (command)
       parser_state &= ~PST_ALEXPNEXT;
 #endif /* ALIAS */
 
+      parser_state &= ~PST_ASSIGNOK;
+
       return (character);
     }
 
@@ -3910,6 +3931,8 @@ read_token (command)
        parser_state &= ~PST_ALEXPNEXT;
 #endif /* ALIAS */
 
+      parser_state &= ~PST_ASSIGNOK;
+
       peek_char = shell_getc (1);
       if (character == peek_char)
        {
@@ -3937,6 +3960,7 @@ read_token (command)
 #if defined (ALIAS)
              parser_state &= ~PST_ALEXPNEXT;
 #endif /* ALIAS */
+
              return (SEMI_SEMI);
 
            case '&':
@@ -4017,13 +4041,14 @@ read_token (command)
 /*
  * Match a $(...) or other grouping construct.  This has to handle embedded
  * quoted strings ('', ``, "") and nested constructs.  It also must handle
- * reprompting the user, if necessary, after reading a newline (unless the
- * P_NONL flag is passed), and returning correct error values if it reads
- * EOF.
+ * reprompting the user, if necessary, after reading a newline, and returning
+ * correct error values if it reads EOF.
  */
 #define P_FIRSTCLOSE   0x01
 #define P_ALLOWESC     0x02
 #define P_DQUOTE       0x04
+#define P_COMMAND      0x08    /* parsing a command, so look for comments */
+#define P_BACKQUOTE    0x10    /* parsing a backquoted command substitution */
 
 static char matched_pair_error;
 static char *
@@ -4032,13 +4057,15 @@ parse_matched_pair (qc, open, close, lenp, flags)
      int open, close;
      int *lenp, flags;
 {
-  int count, ch, was_dollar;
-  int pass_next_character, nestlen, ttranslen, start_lineno;
+  int count, ch, was_dollar, in_comment, check_comment;
+  int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno;
   char *ret, *nestret, *ttrans;
   int retind, retsize, rflags;
 
+/* itrace("parse_matched_pair: open = %c close = %c", open, close); */
   count = 1;
-  pass_next_character = was_dollar = 0;
+  pass_next_character = backq_backslash = was_dollar = in_comment = 0;
+  check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
 
   /* RFLAGS is the set of flags we want to pass to recursive calls. */
   rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
@@ -4049,7 +4076,8 @@ parse_matched_pair (qc, open, close, lenp, flags)
   start_lineno = line_number;
   while (count)
     {
-      ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0);
+      ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0);
+
       if (ch == EOF)
        {
          free (ret);
@@ -4062,6 +4090,30 @@ parse_matched_pair (qc, open, close, lenp, flags)
       if (ch == '\n' && SHOULD_PROMPT ())
        prompt_again ();
 
+      if (in_comment)
+       {
+         /* Add this character. */
+         RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
+         ret[retind++] = ch;
+
+         if (ch == '\n')
+           in_comment = 0;
+
+         continue;
+       }
+      /* Not exactly right yet, should handle shell metacharacters, too.  If
+        any changes are made to this test, make analogous changes to subst.c:
+        extract_delimited_string(). */
+      else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1])))
+       in_comment = 1;
+
+      /* last char was backslash inside backquoted command substitution */
+      if (backq_backslash)
+       {
+         backq_backslash = 0;
+         /* Placeholder for adding special characters */
+       }
+
       if (pass_next_character)         /* last char was backslash */
        {
          pass_next_character = 0;
@@ -4086,11 +4138,9 @@ parse_matched_pair (qc, open, close, lenp, flags)
        }
       else if MBTEST(ch == close)              /* ending delimiter */
        count--;
-#if 1
       /* handle nested ${...} specially. */
       else if MBTEST(open != close && was_dollar && open == '{' && ch == open) /* } */
        count++;
-#endif
       else if MBTEST(((flags & P_FIRSTCLOSE) == 0) && ch == open)      /* nested begin */
        count++;
 
@@ -4102,6 +4152,10 @@ parse_matched_pair (qc, open, close, lenp, flags)
        {
          if MBTEST((flags & P_ALLOWESC) && ch == '\\')
            pass_next_character++;
+#if 0
+         else if MBTEST((flags & P_BACKQUOTE) && ch == '\\')
+           backq_backslash++;
+#endif
          continue;
        }
 
@@ -4129,9 +4183,18 @@ parse_matched_pair (qc, open, close, lenp, flags)
                  /* Translate $'...' here. */
                  ttrans = ansiexpand (nestret, 0, nestlen - 1, &ttranslen);
                  xfree (nestret);
-                 nestret = sh_single_quote (ttrans);
-                 free (ttrans);
-                 nestlen = strlen (nestret);
+
+                 if ((rflags & P_DQUOTE) == 0)
+                   {
+                     nestret = sh_single_quote (ttrans);
+                     free (ttrans);
+                     nestlen = strlen (nestret);
+                   }
+                 else
+                   {
+                     nestret = ttrans;
+                     nestlen = ttranslen;
+                   }
                  retind -= 2;          /* back up before the $' */
                }
              else if MBTEST(was_dollar && ch == '"' && (extended_quote || (rflags & P_DQUOTE) == 0))
@@ -4139,13 +4202,10 @@ parse_matched_pair (qc, open, close, lenp, flags)
                  /* Locale expand $"..." here. */
                  ttrans = localeexpand (nestret, 0, nestlen - 1, start_lineno, &ttranslen);
                  xfree (nestret);
-                 nestret = (char *)xmalloc (ttranslen + 3);
-                 nestret[0] = '"';
-                 strcpy (nestret + 1, ttrans);
-                 nestret[ttranslen + 1] = '"';
-                 nestret[ttranslen += 2] = '\0';
+
+                 nestret = sh_mkdoublequoted (ttrans, ttranslen, 0);
                  free (ttrans);
-                 nestlen = ttranslen;
+                 nestlen = ttranslen + 2;
                  retind -= 2;          /* back up before the $" */
                }
 
@@ -4164,6 +4224,7 @@ parse_matched_pair (qc, open, close, lenp, flags)
       else if MBTEST(open == '"' && ch == '`')
        {
          nestret = parse_matched_pair (0, '`', '`', &nestlen, rflags);
+add_nestret:
          if (nestret == &matched_pair_error)
            {
              free (ret);
@@ -4177,29 +4238,30 @@ parse_matched_pair (qc, open, close, lenp, flags)
            }
          FREE (nestret);
        }
-      else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '['))      /* ) } ] */
+#if 0
+      else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
+       {
+         /* Add P_BACKQUOTE so backslash quotes the next character and
+            shell_getc does the right thing with \<newline>.  We do this for
+            a measure  of backwards compatibility -- it's not strictly the
+            right POSIX thing. */
+         nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE);
+         goto add_nestret;
+       }
+#endif
+      else if MBTEST(open != '`' && was_dollar && (ch == '(' || ch == '{' || ch == '['))       /* ) } ] */
        /* check for $(), $[], or ${} inside quoted string. */
        {
          if (open == ch)       /* undo previous increment */
            count--;
          if (ch == '(')                /* ) */
-           nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags);
+           nestret = parse_matched_pair (0, '(', ')', &nestlen, rflags & ~P_DQUOTE);
          else if (ch == '{')           /* } */
            nestret = parse_matched_pair (0, '{', '}', &nestlen, P_FIRSTCLOSE|rflags);
          else if (ch == '[')           /* ] */
            nestret = parse_matched_pair (0, '[', ']', &nestlen, rflags);
-         if (nestret == &matched_pair_error)
-           {
-             free (ret);
-             return &matched_pair_error;
-           }
-         if (nestlen)
-           {
-             RESIZE_MALLOCED_BUFFER (ret, retind, nestlen, retsize, 64);
-             strcpy (ret + retind, nestret);
-             retind += nestlen;
-           }
-         FREE (nestret);
+
+         goto add_nestret;
        }
       was_dollar = MBTEST(ch == '$');
     }
@@ -4219,8 +4281,8 @@ static int
 parse_dparen (c)
      int c;
 {
-  int cmdtyp, len, sline;
-  char *wval, *wv2;
+  int cmdtyp, sline;
+  char *wval;
   WORD_DESC *wd;
 
 #if defined (ARITH_FOR_COMMAND)
@@ -4230,9 +4292,9 @@ parse_dparen (c)
       cmdtyp = parse_arith_cmd (&wval, 0);
       if (cmdtyp == 1)
        {
-         wd = make_word (wval);
+         wd = alloc_word_desc ();
+         wd->word = wval;
          yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);
-         free (wval);
          return (ARITH_FOR_EXPRS);
        }
       else
@@ -4244,21 +4306,14 @@ parse_dparen (c)
   if (reserved_word_acceptable (last_read_token))
     {
       sline = line_number;
-#if 0
-      cmdtyp = parse_arith_cmd (&wval, 1);
-#else
+
       cmdtyp = parse_arith_cmd (&wval, 0);
-#endif
       if (cmdtyp == 1) /* arithmetic command */
        {
-         wd = make_word (wval);
-#if 0
-         wd->flags = W_QUOTED;
-#else
-         wd->flags = W_QUOTED|W_NOSPLIT|W_NOGLOB;
-#endif
+         wd = alloc_word_desc ();
+         wd->word = wval;
+         wd->flags = W_QUOTED|W_NOSPLIT|W_NOGLOB|W_DQUOTE;
          yylval.word_list = make_word_list (wd, (WORD_LIST *)NULL);
-         free (wval);  /* make_word copies it */
          return (ARITH_CMD);
        }
       else if (cmdtyp == 0)    /* nested subshell */
@@ -4576,6 +4631,7 @@ token_is_assignment (t, i)
   return r;
 }
 
+/* XXX - possible changes here for `+=' */
 static int
 token_is_ident (t, i)
      char *t;
@@ -4608,6 +4664,10 @@ read_token_word (character)
   /* DOLLAR_PRESENT becomes non-zero if we see a `$'. */
   int dollar_present;
 
+  /* COMPOUND_ASSIGNMENT becomes non-zero if we are parsing a compound
+     assignment. */
+  int compound_assignment;
+
   /* QUOTED becomes non-zero if we see one of ("), ('), (`), or (\). */
   int quoted;
 
@@ -4627,7 +4687,7 @@ read_token_word (character)
 
   token_index = 0;
   all_digit_token = DIGIT (character);
-  dollar_present = quoted = pass_next_character = 0;
+  dollar_present = quoted = pass_next_character = compound_assignment = 0;
 
   for (;;)
     {
@@ -4673,7 +4733,7 @@ read_token_word (character)
       if MBTEST(shellquote (character))
        {
          push_delimiter (dstack, character);
-         ttok = parse_matched_pair (character, character, character, &ttoklen, 0);
+         ttok = parse_matched_pair (character, character, character, &ttoklen, (character == '`') ? P_COMMAND : 0);
          pop_delimiter (dstack);
          if (ttok == &matched_pair_error)
            return -1;          /* Bail immediately. */
@@ -4736,7 +4796,7 @@ read_token_word (character)
                     history literally rather than causing a possibly-
                     incorrect `;' to be added. ) */
                  push_delimiter (dstack, peek_char);
-                 ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
+                 ttok = parse_matched_pair (cd, '(', ')', &ttoklen, P_COMMAND);
                  pop_delimiter (dstack);
                }
              else
@@ -4772,13 +4832,14 @@ read_token_word (character)
                {
                  ttrans = ansiexpand (ttok, 0, ttoklen - 1, &ttranslen);
                  free (ttok);
+
                  /* Insert the single quotes and correctly quote any
                     embedded single quotes (allowed because P_ALLOWESC was
                     passed to parse_matched_pair). */
                  ttok = sh_single_quote (ttrans);
                  free (ttrans);
+                 ttranslen = strlen (ttok);
                  ttrans = ttok;
-                 ttranslen = strlen (ttrans);
                }
              else
                {
@@ -4787,12 +4848,9 @@ read_token_word (character)
                  free (ttok);
 
                  /* Add the double quotes back */
-                 ttok = (char *)xmalloc (ttranslen + 3);
-                 ttok[0] = '"';
-                 strcpy (ttok + 1, ttrans);
-                 ttok[ttranslen + 1] = '"';
-                 ttok[ttranslen += 2] = '\0';
+                 ttok = sh_mkdoublequoted (ttrans, ttranslen, 0);
                  free (ttrans);
+                 ttranslen += 2;
                  ttrans = ttok;
                }
 
@@ -4845,7 +4903,7 @@ read_token_word (character)
          goto next_character;
         }
       /* Identify possible compound array variable assignment. */
-      else if MBTEST(character == '=' && token_index > 0 && token_is_assignment (token, token_index))
+      else if MBTEST(character == '=' && token_index > 0 && (assignment_acceptable (last_read_token) || (parser_state & PST_ASSIGNOK)) && token_is_assignment (token, token_index))
        {
          peek_char = shell_getc (1);
          if MBTEST(peek_char == '(')           /* ) */
@@ -4866,7 +4924,12 @@ read_token_word (character)
              token[token_index++] = ')';
              FREE (ttok);
              all_digit_token = 0;
+             compound_assignment = 1;
+#if 1
              goto next_character;
+#else
+             goto got_token;           /* ksh93 seems to do this */
+#endif
            }
          else
            shell_ungetc (peek_char);
@@ -4960,7 +5023,9 @@ got_token:
   if (dollar_present)
     the_word->flags |= W_HASDOLLAR;
   if (quoted)
-    the_word->flags |= W_QUOTED;
+    the_word->flags |= W_QUOTED;               /*(*/
+  if (compound_assignment && token[token_index-1] == ')')
+    the_word->flags |= W_COMPASSIGN;
   /* A word is an assignment if it appears at the beginning of a
      simple command, or after another assignment word.  This is
      context-dependent, so it cannot be handled in the grammar. */
@@ -4972,6 +5037,16 @@ got_token:
        the_word->flags |= W_NOSPLIT;
     }
 
+  if (command_token_position (last_read_token))
+    {
+      struct builtin *b;
+      b = builtin_address_internal (token, 0);
+      if (b && (b->flags & ASSIGNMENT_BUILTIN))
+       parser_state |= PST_ASSIGNOK;
+      else if (STREQ (token, "eval") || STREQ (token, "let"))
+       parser_state |= PST_ASSIGNOK;
+    }
+
   yylval.word = the_word;
 
   result = ((the_word->flags & (W_ASSIGNMENT|W_NOSPLIT)) == (W_ASSIGNMENT|W_NOSPLIT))
@@ -5129,6 +5204,8 @@ history_delimiting_chars ()
        return " ";
       return ";";
     }
+  else if (two_tokens_ago == CASE && token_before_that == WORD && (parser_state & PST_CASESTMT))
+    return " ";
 
   for (i = 0; no_semi_successors[i]; i++)
     {
@@ -5246,7 +5323,7 @@ decode_prompt_string (string)
   int last_exit_value;
 #if defined (PROMPT_STRING_DECODE)
   int result_size, result_index;
-  int c, n;
+  int c, n, i;
   char *temp, octal_string[4];
   struct tm *tm;  
   time_t the_time;
@@ -5408,7 +5485,7 @@ decode_prompt_string (string)
            case 'W':
              {
                /* Use the value of PWD because it is much more efficient. */
-               char t_string[PATH_MAX], *t;
+               char t_string[PATH_MAX];
                int tlen;
 
                temp = get_string_value ("PWD");
@@ -5433,7 +5510,7 @@ decode_prompt_string (string)
 #define ROOT_PATH(x)   ((x)[0] == '/' && (x)[1] == 0)
 #define DOUBLE_SLASH_ROOT(x)   ((x)[0] == '/' && (x)[1] == '/' && (x)[2] == 0)
                /* Abbreviate \W as ~ if $PWD == $HOME */
-               if (c == 'W' && (((t = get_string_value ("HOME")) == 0) || STREQ (t, temp) == 0))
+               if (c == 'W' && (((t = get_string_value ("HOME")) == 0) || STREQ (t, t_string) == 0))
                  {
                    if (ROOT_PATH (t_string) == 0 && DOUBLE_SLASH_ROOT (t_string) == 0)
                      {
@@ -5518,9 +5595,12 @@ decode_prompt_string (string)
                  break;
                }
              temp = (char *)xmalloc (3);
-             temp[0] = '\001';
-             temp[1] = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
-             temp[2] = '\0';
+             n = (c == '[') ? RL_PROMPT_START_IGNORE : RL_PROMPT_END_IGNORE;
+             i = 0;
+             if (n == CTLESC || n == CTLNUL)
+               temp[i++] = CTLESC;
+             temp[i++] = n;
+             temp[i] = '\0';
              goto add_string;
 #endif /* READLINE */
 
@@ -5616,15 +5696,15 @@ yyerror (msg)
 }
 
 static char *
-error_token_from_token (token)
-     int token;
+error_token_from_token (tok)
+     int tok;
 {
   char *t;
 
-  if (t = find_token_in_alist (token, word_token_alist, 0))
+  if (t = find_token_in_alist (tok, word_token_alist, 0))
     return t;
 
-  if (t = find_token_in_alist (token, other_token_alist, 0))
+  if (t = find_token_in_alist (tok, other_token_alist, 0))
     return t;
 
   t = (char *)NULL;
@@ -5912,7 +5992,7 @@ parse_string_to_word_list (s, flags, whom)
          line_number = orig_line_number + line_number - 1;
          orig_current_token = current_token;
          current_token = tok;
-         yyerror ((char *)NULL);       /* does the right thing */
+         yyerror (NULL);       /* does the right thing */
          current_token = orig_current_token;
          if (wl)
            dispose_words (wl);
@@ -5958,18 +6038,21 @@ parse_compound_assignment (retlenp)
      int *retlenp;
 {
   WORD_LIST *wl, *rl;
-  int tok, orig_line_number, orig_token_size;
+  int tok, orig_line_number, orig_token_size, orig_last_token, assignok;
   char *saved_token, *ret;
 
   saved_token = token;
   orig_token_size = token_buffer_size;
   orig_line_number = line_number;
+  orig_last_token = last_read_token;
 
   last_read_token = WORD;      /* WORD to allow reserved words here */
 
   token = (char *)NULL;
   token_buffer_size = 0;
 
+  assignok = parser_state&PST_ASSIGNOK;                /* XXX */
+
   wl = (WORD_LIST *)NULL;      /* ( */
   parser_state |= PST_COMPASSIGN;
 
@@ -5987,7 +6070,7 @@ parse_compound_assignment (retlenp)
          if (tok == yacc_EOF)  /* ( */
            parser_error (orig_line_number, _("unexpected EOF while looking for matching `)'"));
          else
-           yyerror ((char *)NULL);     /* does the right thing */
+           yyerror(NULL);      /* does the right thing */
          if (wl)
            dispose_words (wl);
          wl = &parse_string_error;
@@ -6012,7 +6095,8 @@ parse_compound_assignment (retlenp)
        jump_to_top_level (DISCARD);
     }
 
-  last_read_token = WORD;
+  last_read_token = orig_last_token;           /* XXX - was WORD? */
+
   if (wl)
     {
       rl = REVERSE_LIST (wl, WORD_LIST *);
@@ -6024,6 +6108,10 @@ parse_compound_assignment (retlenp)
 
   if (retlenp)
     *retlenp = (ret && *ret) ? strlen (ret) : 0;
+
+  if (assignok)
+    parser_state |= PST_ASSIGNOK;
+
   return ret;
 }
 
@@ -6042,7 +6130,7 @@ save_parser_state (ps)
 #endif
 
   if (ps == 0)
-    ps = xmalloc (sizeof (sh_parser_state_t));
+    ps = (sh_parser_state_t *)xmalloc (sizeof (sh_parser_state_t));
   if (ps == 0)
     return ((sh_parser_state_t *)NULL);