Skip to content

Commit ab88fba

Browse files
committed
(chocolatey#1762) pin exit 2 if nothing to do
If enhanced exit codes are enabled, this sets the pin command to exit with 2 if there is nothing to do (i.e. if NOCHANGEMESSAGE is output).
1 parent bf83b68 commit ab88fba

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/chocolatey/infrastructure.app/commands/ChocolateyPinCommand.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,17 @@ Exit codes that normally result from running this command.
128128
Normal:
129129
- 0: operation was successful, no issues detected
130130
- -1 or 1: an error has occurred
131+
- 2: nothing to do (enhanced)
132+
133+
NOTE: Starting in v0.10.12, if you have the feature '{0}'
134+
turned on, then choco will provide enhanced exit codes that allow
135+
better integration and scripting.
131136
132137
If you find other exit codes that we have not yet documented, please
133138
file a ticket so we can document it at
134139
https://github.com/chocolatey/choco/issues/new/choose.
135140
136-
");
141+
".format_with(ApplicationParameters.Features.UseEnhancedExitCodes));
137142

138143
"chocolatey".Log().Info(ChocolateyLoggers.Important, "Options and Switches");
139144
}
@@ -218,6 +223,11 @@ public virtual void set_pin(IPackageManager packageManager, ChocolateyConfigurat
218223
else
219224
{
220225
this.Log().Warn(NO_CHANGE_MESSAGE);
226+
227+
if (config.Features.UseEnhancedExitCodes && Environment.ExitCode == 0)
228+
{
229+
Environment.ExitCode = 2;
230+
}
221231
}
222232
}
223233

0 commit comments

Comments
 (0)