Skip to content

Commit b5e5612

Browse files
committed
Exit Windows scripts promptly on failure
When invoking the elasticsearch-env.bat batch script on Windows, if the script exits due to an error (e.g., Java can not be found, or the wrong version of Java is found), then the script exits. Sadly, on Windows, this does not also terminate the caller, instead returning control. This means we have to explicitly exit so that is what we do in this commit. Relates #25959
1 parent 062be23 commit b5e5612

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

distribution/src/main/resources/bin/elasticsearch-env.bat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ if defined JAVA_HOME (
2525

2626
if not exist %JAVA% (
2727
echo could not find java; set JAVA_HOME or ensure java is in PATH 1>&2
28-
exit /B 1
28+
exit /b 1
2929
)
3030

3131
rem JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we
@@ -41,7 +41,7 @@ rem check the Java version
4141
if errorlevel 1 (
4242
echo|set /p="the minimum required Java version is 8; "
4343
echo your Java version from %JAVA% does not meet this requirement
44-
exit /B 1
44+
exit /b 1
4545
)
4646

4747
if "%CONF_DIR%" == "" (

distribution/src/main/resources/bin/elasticsearch-keystore.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setlocal enabledelayedexpansion
44

5-
call "%~dp0elasticsearch-env.bat"
5+
call "%~dp0elasticsearch-env.bat" || exit /b 1
66

77
%JAVA% ^
88
%ES_JAVA_OPTS% ^

distribution/src/main/resources/bin/elasticsearch-plugin.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setlocal enabledelayedexpansion
44

5-
call "%~dp0elasticsearch-env.bat"
5+
call "%~dp0elasticsearch-env.bat" || exit /b 1
66

77
%JAVA% ^
88
%ES_JAVA_OPTS% ^

distribution/src/main/resources/bin/elasticsearch-service.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setlocal enabledelayedexpansion
44

5-
call "%~dp0elasticsearch-env.bat"
5+
call "%~dp0elasticsearch-env.bat" || exit /b 1
66

77
set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe
88
set SERVICE_ID=elasticsearch-service-x64

distribution/src/main/resources/bin/elasticsearch-translog.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setlocal enabledelayedexpansion
44

5-
call "%~dp0elasticsearch-env.bat"
5+
call "%~dp0elasticsearch-env.bat" || exit /b 1
66

77
%JAVA% ^
88
%ES_JAVA_OPTS% ^

distribution/src/main/resources/bin/elasticsearch.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO (
3232
)
3333
)
3434

35-
CALL "%~dp0elasticsearch-env.bat"
35+
CALL "%~dp0elasticsearch-env.bat" || exit /b 1
3636
IF ERRORLEVEL 1 (
3737
IF NOT DEFINED nopauseonerror (
3838
PAUSE

0 commit comments

Comments
 (0)