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" +
"This message will be removed when this version is officially released.",
:prefix => false)
result = env.ui.ask("If you're sure you'd like to continue, type 'Y' and then enter: ")
exit 0 if result && result.upcase != "Y"
result = nil
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
logger.debug("Loading environment")

View File

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