50ece2
diff --git a/parse.y b/parse.y
50ece2
--- a/parse.y
50ece2
+++ b/parse.y
50ece2
@@ -4011,11 +4011,13 @@ eof_error:
50ece2
 		  tflags |= LEX_RESWDOK;
50ece2
 		  lex_rwlen = 0;
50ece2
 		}
50ece2
-	       else
50ece2
+	       else if (shellmeta (ch) == 0)
50ece2
 		{
50ece2
 		  tflags &= ~LEX_RESWDOK;
50ece2
 /*itrace("parse_comsub:%d: found `%.4s', lex_reswdok -> 0", line_number, ret+retind-4);*/
50ece2
 		}
50ece2
+	      else	/* can't be in a reserved word any more */
50ece2
+	        lex_rwlen = 0;
50ece2
 	    }
50ece2
 	  else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0)))
50ece2
 	    ;	/* don't modify LEX_RESWDOK if we're starting a comment */