mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 16:32:57 +00:00
[CMD] Add a ExecuteCommandWithEcho() helper and use it in Batch() and as the implementation of RunInstance() FOR-loop helper.
This commit is contained in:
parent
ce543fbb72
commit
240f6737e9
4 changed files with 34 additions and 26 deletions
|
@ -353,18 +353,9 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* JPP 19980807 */
|
/* JPP 19980807 */
|
||||||
/* Echo batch file line */
|
/* Echo the command and execute it */
|
||||||
if (bEcho && !bDisableBatchEcho && Cmd->Type != C_QUIET)
|
|
||||||
{
|
|
||||||
if (!bIgnoreEcho)
|
|
||||||
ConOutChar(_T('\n'));
|
|
||||||
PrintPrompt();
|
|
||||||
EchoCommand(Cmd);
|
|
||||||
ConOutChar(_T('\n'));
|
|
||||||
}
|
|
||||||
|
|
||||||
bc->current = Cmd;
|
bc->current = Cmd;
|
||||||
ret = ExecuteCommand(Cmd);
|
ret = ExecuteCommandWithEcho(Cmd);
|
||||||
FreeCommand(Cmd);
|
FreeCommand(Cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -769,7 +769,8 @@ failed:
|
||||||
}
|
}
|
||||||
|
|
||||||
INT
|
INT
|
||||||
ExecuteCommand(PARSED_COMMAND *Cmd)
|
ExecuteCommand(
|
||||||
|
IN PARSED_COMMAND *Cmd)
|
||||||
{
|
{
|
||||||
PARSED_COMMAND *Sub;
|
PARSED_COMMAND *Sub;
|
||||||
LPTSTR First, Rest;
|
LPTSTR First, Rest;
|
||||||
|
@ -830,6 +831,24 @@ ExecuteCommand(PARSED_COMMAND *Cmd)
|
||||||
return Ret;
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
INT
|
||||||
|
ExecuteCommandWithEcho(
|
||||||
|
IN PARSED_COMMAND *Cmd)
|
||||||
|
{
|
||||||
|
/* Echo the reconstructed command line */
|
||||||
|
if (bEcho && !bDisableBatchEcho && Cmd->Type != C_QUIET)
|
||||||
|
{
|
||||||
|
if (!bIgnoreEcho)
|
||||||
|
ConOutChar(_T('\n'));
|
||||||
|
PrintPrompt();
|
||||||
|
EchoCommand(Cmd);
|
||||||
|
ConOutChar(_T('\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Run the command */
|
||||||
|
return ExecuteCommand(Cmd);
|
||||||
|
}
|
||||||
|
|
||||||
LPTSTR
|
LPTSTR
|
||||||
GetEnvVar(LPCTSTR varName)
|
GetEnvVar(LPCTSTR varName)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,7 +80,15 @@ INT ConvertULargeInteger(ULONGLONG num, LPTSTR des, UINT len, BOOL bPutSeparator
|
||||||
HANDLE RunFile(DWORD, LPTSTR, LPTSTR, LPTSTR, INT);
|
HANDLE RunFile(DWORD, LPTSTR, LPTSTR, LPTSTR, INT);
|
||||||
INT ParseCommandLine(LPTSTR);
|
INT ParseCommandLine(LPTSTR);
|
||||||
struct _PARSED_COMMAND;
|
struct _PARSED_COMMAND;
|
||||||
INT ExecuteCommand(struct _PARSED_COMMAND *Cmd);
|
|
||||||
|
INT
|
||||||
|
ExecuteCommand(
|
||||||
|
IN struct _PARSED_COMMAND *Cmd);
|
||||||
|
|
||||||
|
INT
|
||||||
|
ExecuteCommandWithEcho(
|
||||||
|
IN struct _PARSED_COMMAND *Cmd);
|
||||||
|
|
||||||
LPCTSTR GetEnvVarOrSpecial ( LPCTSTR varName );
|
LPCTSTR GetEnvVarOrSpecial ( LPCTSTR varName );
|
||||||
VOID AddBreakHandler (VOID);
|
VOID AddBreakHandler (VOID);
|
||||||
VOID RemoveBreakHandler (VOID);
|
VOID RemoveBreakHandler (VOID);
|
||||||
|
|
|
@ -69,19 +69,9 @@ static BOOL GetNextElement(TCHAR **pStart, TCHAR **pEnd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Execute a single instance of a FOR command */
|
/* Execute a single instance of a FOR command */
|
||||||
static INT RunInstance(PARSED_COMMAND *Cmd)
|
/* Just run the command (variable expansion is done in DoDelayedExpansion) */
|
||||||
{
|
#define RunInstance(Cmd) \
|
||||||
if (bEcho && !bDisableBatchEcho && Cmd->Subcommands->Type != C_QUIET)
|
ExecuteCommandWithEcho((Cmd)->Subcommands)
|
||||||
{
|
|
||||||
if (!bIgnoreEcho)
|
|
||||||
ConOutChar(_T('\n'));
|
|
||||||
PrintPrompt();
|
|
||||||
EchoCommand(Cmd->Subcommands);
|
|
||||||
ConOutChar(_T('\n'));
|
|
||||||
}
|
|
||||||
/* Just run the command (variable expansion is done in DoDelayedExpansion) */
|
|
||||||
return ExecuteCommand(Cmd->Subcommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if this FOR should be terminated early */
|
/* Check if this FOR should be terminated early */
|
||||||
static BOOL Exiting(PARSED_COMMAND *Cmd)
|
static BOOL Exiting(PARSED_COMMAND *Cmd)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue