exit(1) does not set exit code in Windows?
조회 수: 9 (최근 30일)
이전 댓글 표시
hi
I'm trying to write a test-suite for MATLAB code. In my test script, I use exit(1) to be able to tell my build system (make) if the test failed. This works fine on Linux and MacOS. However, on Windows, the return code of MATLAB is always 0, even with the following
C:\Users\Kris>matlab -nodisplay -nosplash -nojvm -r "exit(1)"
C:\Users\Kris>echo %ERRORLEVEL%
0
Is this a bug, or do I misunderstand something? I'm using R2014b.
댓글 수: 0
답변 (2개)
Walter Roberson
2015년 9월 5일
As an experiment, referring to http://www.mathworks.com/matlabcentral/answers/100904-how-can-i-retrieve-an-exit-code-from-a-stand-alone-created-using-matlab-compiler-4-10-r2009a, perhaps if you use "start /wait" to launch MATLAB ?
Tyler Cumby
2018년 7월 18일
This question is a bit old, but for those who still have it, instead of calling the matlab.exe in <MATLAB root>/bin, call MATLAB.exe in <MATLAB root>/bin/<arch>. That is,
start /wait "%PROGRAMFILES%\MATLAB\R2017b\bin\win64\MATLAB.exe" -nodesktop -nosplash -r "exit(1)"
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!