mirror of
https://github.com/reactos/reactos.git
synced 2025-07-29 09:12:20 +00:00
[CMD] Add a MSCMD_BATCH_ECHO define for enabling Windows' CMD.EXE way of preserving/restoring the echo flag across batch calls.
Observation shows that this is done only when the top-level batch file is being run (and then terminates); the echo flag is not restored to its previous state when a child batch file terminates and gives main back to its parent batch.
This commit is contained in:
parent
141378cfc8
commit
87a5403318
2 changed files with 30 additions and 0 deletions
|
@ -66,6 +66,10 @@
|
||||||
BATCH_TYPE BatType = NONE;
|
BATCH_TYPE BatType = NONE;
|
||||||
PBATCH_CONTEXT bc = NULL;
|
PBATCH_CONTEXT bc = NULL;
|
||||||
|
|
||||||
|
#ifdef MSCMD_BATCH_ECHO
|
||||||
|
BOOL bBcEcho = TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
BOOL bEcho = TRUE; /* The echo flag */
|
BOOL bEcho = TRUE; /* The echo flag */
|
||||||
|
|
||||||
/* Buffer for reading Batch file lines */
|
/* Buffer for reading Batch file lines */
|
||||||
|
@ -195,8 +199,10 @@ VOID ExitBatch(VOID)
|
||||||
UndoRedirection(bc->RedirList, NULL);
|
UndoRedirection(bc->RedirList, NULL);
|
||||||
FreeRedirection(bc->RedirList);
|
FreeRedirection(bc->RedirList);
|
||||||
|
|
||||||
|
#ifndef MSCMD_BATCH_ECHO
|
||||||
/* Preserve echo state across batch calls */
|
/* Preserve echo state across batch calls */
|
||||||
bEcho = bc->bEcho;
|
bEcho = bc->bEcho;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (bc->setlocal)
|
while (bc->setlocal)
|
||||||
cmd_endlocal(_T(""));
|
cmd_endlocal(_T(""));
|
||||||
|
@ -213,6 +219,10 @@ VOID ExitBatch(VOID)
|
||||||
{
|
{
|
||||||
CheckCtrlBreak(BREAK_OUTOFBATCH);
|
CheckCtrlBreak(BREAK_OUTOFBATCH);
|
||||||
BatType = NONE;
|
BatType = NONE;
|
||||||
|
|
||||||
|
#ifdef MSCMD_BATCH_ECHO
|
||||||
|
bEcho = bBcEcho;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +362,9 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
bc->mempos = 0; /* Go to the beginning of the batch file */
|
bc->mempos = 0; /* Go to the beginning of the batch file */
|
||||||
|
#ifndef MSCMD_BATCH_ECHO
|
||||||
bc->bEcho = bEcho; /* Preserve echo across batch calls */
|
bc->bEcho = bEcho; /* Preserve echo across batch calls */
|
||||||
|
#endif
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < 10; i++)
|
||||||
bc->shiftlevel[i] = i;
|
bc->shiftlevel[i] = i;
|
||||||
|
|
||||||
|
@ -381,6 +393,10 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
||||||
{
|
{
|
||||||
BatType = CMD_TYPE;
|
BatType = CMD_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MSCMD_BATCH_ECHO
|
||||||
|
bBcEcho = bEcho;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if this is a "CALL :label" */
|
/* Check if this is a "CALL :label" */
|
||||||
|
@ -424,6 +440,10 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
||||||
{
|
{
|
||||||
/* Reset the top-level batch context type */
|
/* Reset the top-level batch context type */
|
||||||
BatType = NONE;
|
BatType = NONE;
|
||||||
|
|
||||||
|
#ifdef MSCMD_BATCH_ECHO
|
||||||
|
bEcho = bBcEcho;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore the FOR variables */
|
/* Restore the FOR variables */
|
||||||
|
|
|
@ -19,6 +19,10 @@ typedef enum _BATCH_TYPE
|
||||||
CMD_TYPE /* New-style NT OS/2 batch file */
|
CMD_TYPE /* New-style NT OS/2 batch file */
|
||||||
} BATCH_TYPE;
|
} BATCH_TYPE;
|
||||||
|
|
||||||
|
|
||||||
|
/* Enable this define for Windows' CMD batch-echo behaviour compatibility */
|
||||||
|
#define MSCMD_BATCH_ECHO
|
||||||
|
|
||||||
typedef struct _BATCH_CONTEXT
|
typedef struct _BATCH_CONTEXT
|
||||||
{
|
{
|
||||||
struct _BATCH_CONTEXT *prev;
|
struct _BATCH_CONTEXT *prev;
|
||||||
|
@ -30,7 +34,9 @@ typedef struct _BATCH_CONTEXT
|
||||||
LPTSTR params;
|
LPTSTR params;
|
||||||
LPTSTR raw_params; /* Holds the raw params given by the input */
|
LPTSTR raw_params; /* Holds the raw params given by the input */
|
||||||
INT shiftlevel[10];
|
INT shiftlevel[10];
|
||||||
|
#ifndef MSCMD_BATCH_ECHO
|
||||||
BOOL bEcho; /* Preserve echo flag across batch calls */
|
BOOL bEcho; /* Preserve echo flag across batch calls */
|
||||||
|
#endif
|
||||||
REDIRECTION *RedirList;
|
REDIRECTION *RedirList;
|
||||||
PARSED_COMMAND *current;
|
PARSED_COMMAND *current;
|
||||||
struct _SETLOCAL *setlocal;
|
struct _SETLOCAL *setlocal;
|
||||||
|
@ -53,6 +59,10 @@ extern BATCH_TYPE BatType;
|
||||||
extern PBATCH_CONTEXT bc;
|
extern PBATCH_CONTEXT bc;
|
||||||
extern PFOR_CONTEXT fc;
|
extern PFOR_CONTEXT fc;
|
||||||
|
|
||||||
|
#ifdef MSCMD_BATCH_ECHO
|
||||||
|
extern BOOL bBcEcho;
|
||||||
|
#endif
|
||||||
|
|
||||||
extern BOOL bEcho; /* The echo flag */
|
extern BOOL bEcho; /* The echo flag */
|
||||||
|
|
||||||
#define BATCH_BUFFSIZE 8192
|
#define BATCH_BUFFSIZE 8192
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue