Skip to content

Commit 838484f

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 4a0e218 commit 838484f

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
@@ -130,12 +130,17 @@ Exit codes that normally result from running this command.
130130
Normal:
131131
- 0: operation was successful, no issues detected
132132
- -1 or 1: an error has occurred
133+
- 2: nothing to do (enhanced)
134+
135+
NOTE: Starting in v2.3.0, if you have the feature '{0}'
136+
turned on, then choco will provide enhanced exit codes that allow
137+
better integration and scripting.
133138
134139
If you find other exit codes that we have not yet documented, please
135140
file a ticket so we can document it at
136141
https://github.com/chocolatey/choco/issues/new/choose.
137142
138-
");
143+
".FormatWith(ApplicationParameters.Features.UseEnhancedExitCodes));
139144

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

0 commit comments

Comments
 (0)