Implement SETLOCAL and ENDLOCAL commands. Make delayed expansion optional (disabled by default, enabled by CMD /V switch or with SETLOCAL)

svn path=/trunk/; revision=39892
This commit is contained in:
Jeffrey Morlan 2009-03-06 18:05:45 +00:00
parent 64455e3b04
commit fff257c059
5 changed files with 117 additions and 10 deletions

View file

@ -189,6 +189,9 @@ VOID ExitBatch (LPTSTR msg)
/* Preserve echo state across batch calls */
bEcho = bc->bEcho;
while (bc->setlocal)
cmd_endlocal(_T(""));
bc = bc->prev;
}
@ -239,16 +242,23 @@ BOOL Batch (LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd
}
else
{
struct _SETLOCAL *setlocal = NULL;
/* If a batch file runs another batch file as part of a compound command
* (e.g. "x.bat & somethingelse") then the first file gets terminated. */
if (Cmd != NULL)
if (bc && Cmd != NULL)
{
/* Get its SETLOCAL stack so it can be migrated to the new context */
setlocal = bc->setlocal;
bc->setlocal = NULL;
ExitBatch(NULL);
}
/* Create a new context. This function will not
* return until this context has been exited */
new.prev = bc;
bc = &new;
bc->RedirList = NULL;
bc->setlocal = setlocal;
}
GetFullPathName(fullname, sizeof(bc->BatchFilePath) / sizeof(TCHAR), bc->BatchFilePath, NULL);