diff --git a/CHANGELOG.md b/CHANGELOG.md index f532dcaf9..5bf66230d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ FEATURES: setting that accepts a path to a Ruby file to load as part of Chef configuration, allowing you to override any setting available. [GH-876] +IMPROVEMENTS: + + - `vagrant destroy` returns exit status 1 if any of the confirmations + are declined. [GH-923] + BUG FIXES: - core/nfs: Exporting sub-directories of other exported folders now diff --git a/lib/vagrant/action/builtin/confirm.rb b/lib/vagrant/action/builtin/confirm.rb index 8f490e050..7fc6aabbf 100644 --- a/lib/vagrant/action/builtin/confirm.rb +++ b/lib/vagrant/action/builtin/confirm.rb @@ -29,6 +29,7 @@ module Vagrant # The result is only true if the user said "Y" env[:result] = choice && choice.upcase == "Y" + env["#{@force_key}_result".to_sym] = env[:result] @app.call(env) end diff --git a/plugins/commands/destroy/command.rb b/plugins/commands/destroy/command.rb index 3b245f035..e4ac0d6a1 100644 --- a/plugins/commands/destroy/command.rb +++ b/plugins/commands/destroy/command.rb @@ -19,12 +19,17 @@ module VagrantPlugins return if !argv @logger.debug("'Destroy' each target VM...") + declined = false with_target_vms(argv, :reverse => true) do |vm| - vm.action(:destroy, :force_confirm_destroy => options[:force]) + action_env = vm.action( + :destroy, :force_confirm_destroy => options[:force]) + + declined = true if action_env.has_key?(:force_confirm_destroy_result) && + action_env[:force_confirm_destroy_result] == false end - # Success, exit status 0 - 0 + # Success if no confirms were declined + declined ? 1 : 0 end end end