Reputation: 617
In my project, I call java program from the command window. I have a bat file like the following. I throw a RuntimeException in Test class. With "|| exit /b 1", all the commands after ""%JAVA_HOME%\bin\java" -cp "bin/" Test %RUN_ARGS% || exit /b 1" will be skipped.
Can anybody tell me what "|| exit /b 1" does? What is the meaning of "||" in the command line?
@echo off
setlocal
set RUN_ARGS=%*
"%JAVA_HOME%\bin\java" -cp "bin/" Test %RUN_ARGS% || exit /b 1
echo %RUN_ARGS%
dir
endlocal
exit /b 0
Upvotes: 0
Views: 1781
Reputation: 632
exit /B exits the batch file without exiting the command window. In other words, it leaves the command window open after your java process exits so you can review any output. the | is a pipe operator, it passes the output of the java command as input to the exit command.
Upvotes: 0
Reputation: 3456
The double pipe (||
) is used to conditionally execute a command. The command to the right is only executed if the command to the left returns an error level greater than zero.
Upvotes: 1