462fb2
diff -up bash-4.2/parse.y.old bash-4.2/parse.y
462fb2
--- bash-4.2/parse.y.old	2015-05-18 13:04:30.341494305 +0200
462fb2
+++ bash-4.2/parse.y	2015-05-18 13:05:18.245509202 +0200
462fb2
@@ -3693,6 +3693,17 @@ eof_error:
462fb2
 	    }
462fb2
 	  else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0)))
462fb2
 	    ;	/* don't modify LEX_RESWDOK if we're starting a comment */
462fb2
+	  /* Allow `do' followed by space, tab, or newline to preserve the
462fb2
+	     RESWDOK flag, but reset the reserved word length counter so we
462fb2
+	     can read another one. */
462fb2
+	  else if MBTEST(((tflags & LEX_INCASE) == 0) &&
462fb2
+			  (isblank(ch) || ch == '\n') &&
462fb2
+			  lex_rwlen == 2 &&
462fb2
+			  STREQN (ret + retind - 2, "do", 2))
462fb2
+{
462fb2
+/*itrace("parse_comsub:%d: lex_incase == 1 found `%c', found \"do\"", line_number, ch);*/
462fb2
+	    lex_rwlen = 0;
462fb2
+}
462fb2
 	  else if MBTEST((tflags & LEX_INCASE) && ch != '\n')
462fb2
 	    /* If we can read a reserved word and we're in case, we're at the
462fb2
 	       point where we can read a new pattern list or an esac.  We