From ec2721fd3ecafafb7db3c310a5d214c601b76e28 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Wed, 17 Jul 2024 08:34:15 +0900 Subject: [PATCH] [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. --- base/shell/cmd/batch.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/base/shell/cmd/batch.c b/base/shell/cmd/batch.c index f20028af23f..84020b7d1b8 100644 --- a/base/shell/cmd/batch.c +++ b/base/shell/cmd/batch.c @@ -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;