[CMD] Syntax errors during parsing of batch parameters expansion, or FOR and IF commands, are fatal, and batch execution should stop.

- To this purpose use the ParseErrorEx() that correctly sets the
  bParseError flag, and return the partially-parsed command so that
  it gets echoed as well for diagnostics purposes (Windows-compatible).

- Any other parameters specified after (or before) the '/?' switch for
  the FOR and IF commands, are considered fatal syntax errors as well,
  thus we employ the ParseErrorEx() as well.
This commit is contained in:
Hermès Bélusca-Maïto 2020-05-18 02:16:40 +02:00
parent 6eb1cae348
commit 495c82ccde
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
3 changed files with 11 additions and 3 deletions

View file

@ -1208,7 +1208,7 @@ GetBatchVar(TCHAR *varName, UINT *varNameLen)
ret = GetEnhancedVar(&varNameEnd, FindArg);
if (!ret)
{
error_syntax(varName);
ParseErrorEx(varName);
return NULL;
}
*varNameLen = varNameEnd - varName;
@ -1267,6 +1267,14 @@ SubstituteVars(TCHAR *Src, TCHAR *Dest, TCHAR Delim)
{
UINT NameLen;
Var = GetBatchVar(Src, &NameLen);
if (!Var && bParseError)
{
/* Return the partially-parsed command to be
* echoed for error diagnostics purposes. */
APPEND1(Delim);
APPEND(Src, DestEnd-Dest);
return FALSE;
}
if (Var != NULL)
{
VarLength = _tcslen(Var);

View file

@ -44,7 +44,7 @@ INT cmd_for(LPTSTR param)
return 0;
}
error_syntax(param);
ParseErrorEx(param);
return 1;
}

View file

@ -59,7 +59,7 @@ INT cmd_if(LPTSTR param)
return 0;
}
error_syntax(param);
ParseErrorEx(param);
return 1;
}