You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2022/02/11 01:24:17 UTC

[GitHub] [iotdb] ericpai commented on a change in pull request #5026: [IOTDB-2523] Fix exiting with 0 when executing error in cli

ericpai commented on a change in pull request #5026:
URL: https://github.com/apache/iotdb/pull/5026#discussion_r804284610



##########
File path: cli/src/assembly/resources/sbin/start-cli.bat
##########
@@ -59,16 +59,19 @@ echo %PARAMETERS% | findstr /c:"-h ">nul && (set PARAMETERS=%PARAMETERS%) || (se
 echo %PARAMETERS%
 
 "%JAVA_HOME%\bin\java" %JAVA_OPTS% -cp %CLASSPATH% %MAIN_CLASS% %PARAMETERS%
-
+set ret_code=%ERRORLEVEL%
 goto finally
 
 
 :err
 echo JAVA_HOME environment variable must be set!
+set ret_code=1
 pause
 
 
 @REM -----------------------------------------------------------------------------
 :finally
 
-ENDLOCAL
\ No newline at end of file
+ENDLOCAL
+
+EXIT %ret_code%

Review comment:
       In `start-cli.sh`, it uses `exec` to yield the current process to `java`, which means that the exit code is just the same as the one of `java` process(the L83 `exit $?` is useless as it will be never executed). So there's no need to change the script in unix system.
   However, there's no any command like `exec` in Windows. The final exist code of origin `start-cli.bat` is the last command `ENDLOCAL`, which is always 0. So we need to save the code after the `java` command is finished and do an `EXIT $ret_code`.
   The above conclusions can be proved by the test cases modified in this PR.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org