mirror of
https://github.com/reactos/wine.git
synced 2025-01-22 03:49:02 +00:00
cmd.exe: Support exit [/b] returncode.
This commit is contained in:
parent
758a397755
commit
c36664891c
3
programs/cmd/batch.c
Normal file → Executable file
3
programs/cmd/batch.c
Normal file → Executable file
@ -87,13 +87,14 @@ BATCH_CONTEXT *prev_context;
|
||||
context -> command = command;
|
||||
context -> shift_count = 0;
|
||||
context -> prev_context = prev_context;
|
||||
context -> skip_rest = FALSE;
|
||||
|
||||
/*
|
||||
* Work through the file line by line. Specific batch commands are processed here,
|
||||
* the rest are handled by the main command processor.
|
||||
*/
|
||||
|
||||
while (WCMD_fgets (string, sizeof(string), h)) {
|
||||
while (context -> skip_rest == FALSE && WCMD_fgets (string, sizeof(string), h)) {
|
||||
if (strlen(string) == MAXSTRING -1) {
|
||||
WCMD_output_asis( "Line in Batch processing possibly truncated. Using:\n");
|
||||
WCMD_output_asis( string);
|
||||
|
@ -1159,3 +1159,22 @@ BOOL status;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* WCMD_exit
|
||||
*
|
||||
* Exit either the process, or just this batch program
|
||||
*
|
||||
*/
|
||||
|
||||
void WCMD_exit (void) {
|
||||
|
||||
int rc = atoi(param1); /* Note: atoi of empty parameter is 0 */
|
||||
|
||||
if (context && lstrcmpi(quals, "/B") == 0) {
|
||||
errorlevel = rc;
|
||||
context -> skip_rest = TRUE;
|
||||
} else {
|
||||
ExitProcess(rc);
|
||||
}
|
||||
}
|
||||
|
2
programs/cmd/wcmd.h
Normal file → Executable file
2
programs/cmd/wcmd.h
Normal file → Executable file
@ -37,6 +37,7 @@ void WCMD_directory (void);
|
||||
void WCMD_echo (const char *);
|
||||
void WCMD_endlocal (void);
|
||||
void WCMD_enter_paged_mode(void);
|
||||
void WCMD_exit (void);
|
||||
void WCMD_for (char *);
|
||||
void WCMD_give_help (char *command);
|
||||
void WCMD_goto (void);
|
||||
@ -83,6 +84,7 @@ typedef struct {
|
||||
HANDLE h; /* Handle to the open batch file */
|
||||
int shift_count; /* Number of SHIFT commands executed */
|
||||
void *prev_context; /* Pointer to the previous context block */
|
||||
BOOL skip_rest; /* Skip the rest of the batch program and exit */
|
||||
} BATCH_CONTEXT;
|
||||
|
||||
#endif /* !RC_INVOKED */
|
||||
|
5
programs/cmd/wcmdmain.c
Normal file → Executable file
5
programs/cmd/wcmdmain.c
Normal file → Executable file
@ -244,7 +244,7 @@ int main (int argc, char *argv[])
|
||||
else
|
||||
WCMD_process_command(cmd);
|
||||
HeapFree(GetProcessHeap(), 0, cmd);
|
||||
return 0;
|
||||
return errorlevel;
|
||||
}
|
||||
|
||||
SetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), ENABLE_LINE_INPUT |
|
||||
@ -504,7 +504,8 @@ void WCMD_process_command (char *command)
|
||||
WCMD_volume (0, p);
|
||||
break;
|
||||
case WCMD_EXIT:
|
||||
ExitProcess (0);
|
||||
WCMD_exit ();
|
||||
break;
|
||||
default:
|
||||
WCMD_run_program (whichcmd, 0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user