Don't expand FOR variables until execution time, so that special characters in them won't cause unwanted syntactic effects.

For example, "for %a in (^>) do echo %a" should just echo the greater than sign.

svn path=/trunk/; revision=39611
This commit is contained in:
Jeffrey Morlan 2009-02-15 18:18:16 +00:00
parent a5d9170830
commit 9b0334da19
5 changed files with 64 additions and 24 deletions

View file

@ -405,19 +405,14 @@ LPTSTR ReadBatchLine ()
}
/* At this point, fv points to parameter string */
bc->forvalue = fv;
/* Double up % signs so they will get through the parser intact */
while (*sp)
{
if ((*sp == _T('%')) && (*(sp + 1) == bc->forvar))
{
/* replace % var */
dp = _stpcpy (dp, fv);
sp += 2;
}
else
{
/* Else just copy */
*dp++ = *sp++;
}
if (*sp == _T('%'))
*dp++ = _T('%');
*dp++ = *sp++;
}
*dp++ = _T('\n');