From c634cbedccf8f69d8c321a35d0edaab00ae457ce Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 11 Jul 2012 18:47:41 -0700 Subject: [PATCH] Handle interrupts more gracefully on the warning message --- bin/vagrant | 12 ++++++++++-- plugins/commands/destroy/command.rb | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/vagrant b/bin/vagrant index ae682e72e..00daf0339 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -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") diff --git a/plugins/commands/destroy/command.rb b/plugins/commands/destroy/command.rb index 4ffa55395..9c18dafae 100644 --- a/plugins/commands/destroy/command.rb +++ b/plugins/commands/destroy/command.rb @@ -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