-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Closed
Labels
:Delivery/PackagingRPM and deb packaging, tar and zip archives, shell and batch scriptsRPM and deb packaging, tar and zip archives, shell and batch scripts>bugTeam:DeliveryMeta label for Delivery teamMeta label for Delivery team
Description
%ERRORLEVEL% is reported just fine in DOS. Note the CALL is mandatory when calling any batch file and using ||.
$ (CALL bin\elasticsearch-plugin.bat install --batch asfasf) || echo %ERRORLEVEL%
A tool for managing installed elasticsearch plugins
Commands
--------
list - Lists installed elasticsearch plugins
install - Install a plugin
remove - removes a plugin from Elasticsearch
Non-option arguments:
command
Option Description
------ -----------
-h, --help show help
-s, --silent show minimal output
-v, --verbose show verbose output
ERROR: Unknown plugin asfasf
64But on powershell $LASTEXITCODE is 0:
PS> bin\elasticsearch-plugin.bat install --batch asfasf; echo $LASTEXITCODE
A tool for managing installed elasticsearch plugins
<snip>
ERROR: Unknown plugin asfasf
0However if we modify the .bat files we distribute to explicitly exit
endlocal
endlocal
exit /B %ERRORLEVEL%NOTE: ENDLOCAL does not alter %ERRORLEVEL%.
$LASTEXITCODE is set correctly in powershell.
PS > bin\elasticsearch-plugin.bat install --batch asfasf; echo $LASTEXITCODE
A tool for managing installed elasticsearch plugins
<snip>
ERROR: Unknown plugin asfasf
64A similar result is observed when automating the bat files from C#
var bat = @"bin\elasticsearch-plugin.bat";
var args = "install --batch asfasf";
var startInfo = new ProcessStartInfo(bat, args)
{
UseShellExecute = false,
CreateNoWindow = true
};
var p = Process.Start(startInfo);
p.WaitForExit();
var exitCode = p.ExitCode;exitCode will be 0 right now and 64 when we use the explict exit /B %ERRORLEVEL% fix.
Metadata
Metadata
Assignees
Labels
:Delivery/PackagingRPM and deb packaging, tar and zip archives, shell and batch scriptsRPM and deb packaging, tar and zip archives, shell and batch scripts>bugTeam:DeliveryMeta label for Delivery teamMeta label for Delivery team