Handle interrupts more gracefully on the warning message

This commit is contained in:
Mitchell Hashimoto 2012-07-11 18:47:41 -07:00
parent 690d380b77
commit c634cbedcc
2 changed files with 12 additions and 2 deletions

View File

@ -43,8 +43,16 @@ begin
"\n" + "\n" +
"This message will be removed when this version is officially released.", "This message will be removed when this version is officially released.",
:prefix => false) :prefix => false)
result = env.ui.ask("If you're sure you'd like to continue, type 'Y' and then enter: ") result = nil
exit 0 if result && result.upcase != "Y" begin
result = env.ui.ask("If you're sure you'd like to continue, type 'Y' and then enter: ")
rescue Interrupt
result = nil
rescue Vagrant::Errors::UIExpectsTTY
result = nil
end
exit 0 if !result || result.upcase != "Y"
# Load the environment # Load the environment
logger.debug("Loading environment") logger.debug("Loading environment")

View File

@ -29,6 +29,7 @@ module VagrantPlugins
do_destroy = true do_destroy = true
else else
choice = nil choice = nil
begin begin
choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation", choice = @env.ui.ask(I18n.t("vagrant.commands.destroy.confirmation",
:name => vm.name)) :name => vm.name))
@ -41,6 +42,7 @@ module VagrantPlugins
# means the same thing. # means the same thing.
raise Vagrant::Errors::DestroyRequiresForce raise Vagrant::Errors::DestroyRequiresForce
end end
do_destroy = choice.upcase == "Y" do_destroy = choice.upcase == "Y"
end end