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