mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 11:31:40 +00:00
[CMD] Additional fixes for ERRORLEVEL and last returned exit code from EXIT, CALL commands and CMD.
CORE-10495 CORE-13672 - Fix how the ERRORLEVEL and the last returned exit code are set by EXIT and CALL commands, when batch contexts terminate, and when CMD runs in single-command mode (with /C). Addendum to commit26ff2c8e
, and reverts commit7bd33ac4
. See also commit8cf11060
(r40474). More information can be found at: https://ss64.com/nt/exit.html https://stackoverflow.com/a/34987886/13530036 https://stackoverflow.com/a/34937706/13530036 - Move the actual execution of the CMD command-line (in /C or /K single-command mode) from Initialize() to _tmain(), to put it on par with the ProcessInput() interactive mode. - Make ProcessInput() also return the last command's exit code.
This commit is contained in:
parent
4c9d322c68
commit
d78e8029b8
4 changed files with 68 additions and 40 deletions
|
@ -349,7 +349,7 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
|||
|
||||
/* Check if this is a "CALL :label" */
|
||||
if (*firstword == _T(':'))
|
||||
cmd_goto(firstword);
|
||||
ret = cmd_goto(firstword);
|
||||
|
||||
/* If we are calling from inside a FOR, hide the FOR variables */
|
||||
saved_fc = fc;
|
||||
|
@ -376,6 +376,7 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
|||
}
|
||||
/* Stop all execution */
|
||||
ExitAllBatches();
|
||||
ret = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -386,12 +387,11 @@ INT Batch(LPTSTR fullname, LPTSTR firstword, LPTSTR param, PARSED_COMMAND *Cmd)
|
|||
FreeCommand(Cmd);
|
||||
}
|
||||
|
||||
/* Always return the current errorlevel */
|
||||
ret = nErrorLevel;
|
||||
|
||||
TRACE("Batch: returns TRUE\n");
|
||||
|
||||
/* Restore the FOR variables */
|
||||
fc = saved_fc;
|
||||
|
||||
/* Always return the last command's return code */
|
||||
TRACE("Batch: returns %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue