diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs index d7cc757711..ec42541227 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyConfigCommand.cs @@ -128,12 +128,17 @@ Exit codes that normally result from running this command. Normal: - 0: operation was successful, no issues detected - -1 or 1: an error has occurred + - 2: nothing to do, config already set/unset (enhanced) + +NOTE: Starting in v0.10.12, if you have the feature '{0}' + turned on, then choco will provide enhanced exit codes that allow + better integration and scripting. If you find other exit codes that we have not yet documented, please file a ticket so we can document it at https://github.com/chocolatey/choco/issues/new/choose. -"); +".format_with(ApplicationParameters.Features.UseEnhancedExitCodes)); "chocolatey".Log().Info(ChocolateyLoggers.Important, "See It In Action"); "chocolatey".Log().Info(@" diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs index 473eae02c7..4255f10285 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs @@ -441,6 +441,11 @@ public void config_set(ChocolateyConfiguration configuration) if (configuration.ConfigCommand.ConfigValue.is_equal_to(currentValue.to_string())) { this.Log().Warn(NO_CHANGE_MESSAGE); + + if (configuration.Features.UseEnhancedExitCodes && Environment.ExitCode == 0) + { + Environment.ExitCode = 2; + } } else { @@ -458,6 +463,11 @@ public void config_unset(ChocolateyConfiguration configuration) if (config == null || string.IsNullOrEmpty(config.Value)) { this.Log().Warn(NO_CHANGE_MESSAGE); + + if (configuration.Features.UseEnhancedExitCodes && Environment.ExitCode == 0) + { + Environment.ExitCode = 2; + } } else {