From 594ab17b9cef9a14a46762a469d00cc1bbeaf20b Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sun, 30 Jul 2017 13:32:44 +0900 Subject: [PATCH] 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. --- distribution/src/main/resources/bin/elasticsearch-env.bat | 4 ++-- .../src/main/resources/bin/elasticsearch-keystore.bat | 2 +- distribution/src/main/resources/bin/elasticsearch-plugin.bat | 2 +- distribution/src/main/resources/bin/elasticsearch-service.bat | 2 +- .../src/main/resources/bin/elasticsearch-translog.bat | 2 +- distribution/src/main/resources/bin/elasticsearch.bat | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/distribution/src/main/resources/bin/elasticsearch-env.bat b/distribution/src/main/resources/bin/elasticsearch-env.bat index b6cfee2a7673e..591ef494b9614 100644 --- a/distribution/src/main/resources/bin/elasticsearch-env.bat +++ b/distribution/src/main/resources/bin/elasticsearch-env.bat @@ -25,7 +25,7 @@ if defined JAVA_HOME ( if not exist %JAVA% ( echo could not find java; set JAVA_HOME or ensure java is in PATH 1>&2 - exit /B 1 + exit /b 1 ) rem check the Java version @@ -34,7 +34,7 @@ rem check the Java version if errorlevel 1 ( echo|set /p="the minimum required Java version is 8; " echo your Java version from %JAVA% does not meet this requirement - exit /B 1 + exit /b 1 ) rem JAVA_OPTS is not a built-in JVM mechanism but some people think it is so we diff --git a/distribution/src/main/resources/bin/elasticsearch-keystore.bat b/distribution/src/main/resources/bin/elasticsearch-keystore.bat index d7187f13aa802..cea6838d6cee5 100644 --- a/distribution/src/main/resources/bin/elasticsearch-keystore.bat +++ b/distribution/src/main/resources/bin/elasticsearch-keystore.bat @@ -2,7 +2,7 @@ setlocal enabledelayedexpansion -call "%~dp0elasticsearch-env.bat" +call "%~dp0elasticsearch-env.bat" || exit /b 1 %JAVA% ^ %ES_JAVA_OPTS% ^ diff --git a/distribution/src/main/resources/bin/elasticsearch-plugin.bat b/distribution/src/main/resources/bin/elasticsearch-plugin.bat index 7beb8cf53129e..4efbdfc69416e 100644 --- a/distribution/src/main/resources/bin/elasticsearch-plugin.bat +++ b/distribution/src/main/resources/bin/elasticsearch-plugin.bat @@ -2,7 +2,7 @@ setlocal enabledelayedexpansion -call "%~dp0elasticsearch-env.bat" +call "%~dp0elasticsearch-env.bat" || exit /b 1 %JAVA% ^ %ES_JAVA_OPTS% ^ diff --git a/distribution/src/main/resources/bin/elasticsearch-service.bat b/distribution/src/main/resources/bin/elasticsearch-service.bat index f58e39ee0bc4b..bb986d4e663ae 100644 --- a/distribution/src/main/resources/bin/elasticsearch-service.bat +++ b/distribution/src/main/resources/bin/elasticsearch-service.bat @@ -2,7 +2,7 @@ setlocal enabledelayedexpansion -call "%~dp0elasticsearch-env.bat" +call "%~dp0elasticsearch-env.bat" || exit /b 1 set EXECUTABLE=%ES_HOME%\bin\elasticsearch-service-x64.exe set SERVICE_ID=elasticsearch-service-x64 diff --git a/distribution/src/main/resources/bin/elasticsearch-translog.bat b/distribution/src/main/resources/bin/elasticsearch-translog.bat index e34a66ffda15b..f79a1b827951f 100644 --- a/distribution/src/main/resources/bin/elasticsearch-translog.bat +++ b/distribution/src/main/resources/bin/elasticsearch-translog.bat @@ -2,7 +2,7 @@ setlocal enabledelayedexpansion -call "%~dp0elasticsearch-env.bat" +call "%~dp0elasticsearch-env.bat" || exit /b 1 %JAVA% ^ %ES_JAVA_OPTS% ^ diff --git a/distribution/src/main/resources/bin/elasticsearch.bat b/distribution/src/main/resources/bin/elasticsearch.bat index 4845c90c9f52e..fe46c8d788680 100644 --- a/distribution/src/main/resources/bin/elasticsearch.bat +++ b/distribution/src/main/resources/bin/elasticsearch.bat @@ -32,7 +32,7 @@ FOR /F "usebackq tokens=1* delims= " %%A IN (!params!) DO ( ) ) -CALL "%~dp0elasticsearch-env.bat" +CALL "%~dp0elasticsearch-env.bat" || exit /b 1 IF ERRORLEVEL 1 ( IF NOT DEFINED nopauseonerror ( PAUSE