On 12/28/18, Gisle Vanem <gisle.va...@gmail.com> wrote:
> I have trouble understanding why a 'sys.exit(2)' is
> *not* passed back to the CMD shell in this little example:
>
> ----- c:\py_cmd_test.cmd ------
> @%WinDir%\py.exe -2 -x %~dp0py_cmd_test.cmd & exit /b %ERRORLEVEL%

%ERRORLEVEL% gets expanded in the initial parsing before this line is
executed, at which time it is 0. Because of the /b argument, you're
not actually exiting CMD and have no reason to change the error value.
Just use `exit /b`.

Why use CMD as a launcher when you have py.exe with shebang support?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to