Exit batch files explictly using ERRORLEVEL (#29583)

* Exit batch files explictly using ERRORLEVEL

This makes sure the exit code is preserved when calling the batch
files from different contexts other than DOS

Fixes #29582

This also fixes specific error codes being masked by an explict

exit /b 1

causing the useful exitcodes from ExitCodes to be lost.

* fix line breaks for calling cli to match the bash scripts

* indent size of bash files is 2, make sure editorconfig does the same for bat files

* update indenting to match bash files

* update elasticsearch-keystore.bat indenting

* Update elasticsearch-node.bat to exit outside of endlocal
This commit is contained in:
Martijn Laarman 2019-01-25 16:44:33 +01:00 committed by GitHub
parent f1f54e0f61
commit dfecb256cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 46 additions and 12 deletions

View File

@ -8,3 +8,6 @@ indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
[*.bat]
indent_size = 2

View File

@ -21,3 +21,5 @@ if defined ES_ADDITIONAL_CLASSPATH_DIRECTORIES (
-cp "%ES_CLASSPATH%" ^
"%ES_MAIN_CLASS%" ^
%*
exit /b %ERRORLEVEL%

View File

@ -6,7 +6,9 @@ setlocal enableextensions
set ES_MAIN_CLASS=org.elasticsearch.common.settings.KeyStoreCli
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -6,7 +6,9 @@ setlocal enableextensions
set ES_MAIN_CLASS=org.elasticsearch.cluster.coordination.NodeToolCli
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -7,7 +7,10 @@ set ES_MAIN_CLASS=org.elasticsearch.plugins.PluginCli
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/plugin-cli
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -258,3 +258,5 @@ goto:eof
endlocal
endlocal
exit /b %ERRORLEVEL%

View File

@ -6,7 +6,9 @@ setlocal enableextensions
set ES_MAIN_CLASS=org.elasticsearch.index.shard.ShardToolCli
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -55,3 +55,4 @@ cd /d "%ES_HOME%"
endlocal
endlocal
exit /b %ERRORLEVEL%

View File

@ -12,7 +12,9 @@ set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/security-cli
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -12,7 +12,9 @@ set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
set ES_ADDITIONAL_CLASSPATH_DIRECTORIES=lib/tools/security-cli
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -11,7 +11,9 @@ set ES_MAIN_CLASS=org.elasticsearch.xpack.security.authc.esnative.ESNativeRealmM
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -11,7 +11,9 @@ set ES_MAIN_CLASS=org.elasticsearch.xpack.security.authc.saml.SamlMetadataComman
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -11,7 +11,9 @@ set ES_MAIN_CLASS=org.elasticsearch.xpack.security.authc.esnative.tool.SetupPass
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -11,7 +11,9 @@ set ES_MAIN_CLASS=org.elasticsearch.xpack.security.crypto.tool.SystemKeyTool
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -11,7 +11,9 @@ set ES_MAIN_CLASS=org.elasticsearch.xpack.security.authc.file.tool.UsersTool
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-security-env
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%

View File

@ -22,3 +22,4 @@ set CLI_JAR=%ES_HOME%/bin/*
endlocal
endlocal
exit /b %ERRORLEVEL%

View File

@ -11,7 +11,9 @@ set ES_MAIN_CLASS=org.elasticsearch.xpack.watcher.trigger.schedule.tool.CronEval
set ES_ADDITIONAL_SOURCES=x-pack-env;x-pack-watcher-env
call "%~dp0elasticsearch-cli.bat" ^
%%* ^
|| exit /b 1
|| goto exit
endlocal
endlocal
:exit
exit /b %ERRORLEVEL%