[CMD] Batch: Don't ClearBatch if bSameFn (#7112)

Recursing batch was prevented by
ClearBatch call.
JIRA issue: CORE-18093
- Check bSameFn variable.
- If it was TRUE, don't call ClearBatch
  function.
This commit is contained in:
Katayama Hirofumi MZ 2024-07-17 08:34:15 +09:00 committed by GitHub
parent 39305cc79c
commit ec2721fd3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -337,10 +337,11 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
*/
bTopLevel = !bc;
if (bc != NULL && Cmd == bc->current)
if (bc && Cmd == bc->current)
{
/* Then we are transferring to another batch */
ClearBatch();
if (!bSameFn)
ClearBatch();
AddBatchRedirection(&Cmd->Redirections);
}
else
@ -408,17 +409,10 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
/* Perform top-level batch initialization */
if (bTopLevel)
{
TCHAR *dot;
/* Default the top-level batch context type to .BAT */
BatType = BAT_TYPE;
/* If this is a .CMD file, adjust the type */
dot = _tcsrchr(bc->BatchFilePath, _T('.'));
if (dot && (!_tcsicmp(dot, _T(".cmd"))))
{
BatType = CMD_TYPE;
}
/* Default the top-level batch context type
* to .BAT, unless this is a .CMD file */
PTCHAR dotext = _tcsrchr(bc->BatchFilePath, _T('.'));
BatType = (dotext && (!_tcsicmp(dotext, _T(".cmd")))) ? CMD_TYPE : BAT_TYPE;
#ifdef MSCMD_BATCH_ECHO
bBcEcho = bEcho;