diff --git a/bin/vagrant b/bin/vagrant index 0703bd17a..25780759f 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -39,8 +39,8 @@ begin logger.debug("Loading environment") env.load! - # Execute the CLI interface - env.cli(ARGV) + # Execute the CLI interface, and exit with the proper error code + exit(env.cli(ARGV)) rescue Vagrant::Errors::VagrantError => e logger.error("Vagrant experienced an error! Details:") logger.error(e.inspect) diff --git a/lib/vagrant/cli.rb b/lib/vagrant/cli.rb index 0133daedd..974e98bab 100644 --- a/lib/vagrant/cli.rb +++ b/lib/vagrant/cli.rb @@ -34,8 +34,10 @@ module Vagrant return help if !command_class || !@sub_command @logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}") - # Initialize and execute the command class. - command_class.new(@sub_args, @env).execute + # Initialize and execute the command class, returning the exit status. + result = command_class.new(@sub_args, @env).execute + result = 0 if !result.is_a?(Fixnum) + return result end # This prints out the help for the CLI. diff --git a/lib/vagrant/command/box_add.rb b/lib/vagrant/command/box_add.rb index 15600c0d8..82417e6cb 100644 --- a/lib/vagrant/command/box_add.rb +++ b/lib/vagrant/command/box_add.rb @@ -28,6 +28,9 @@ module Vagrant end @env.boxes.add(argv[0], argv[1]) + + # Success, exit status 0 + 0 end end end diff --git a/lib/vagrant/command/box_list.rb b/lib/vagrant/command/box_list.rb index 5adf11c05..4d3f40e06 100644 --- a/lib/vagrant/command/box_list.rb +++ b/lib/vagrant/command/box_list.rb @@ -19,7 +19,10 @@ module Vagrant return @env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), :prefix => false) end boxes.each { |b| @env.ui.info(b.name, :prefix => false) } - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/box_remove.rb b/lib/vagrant/command/box_remove.rb index 7d733e10c..77e828900 100644 --- a/lib/vagrant/command/box_remove.rb +++ b/lib/vagrant/command/box_remove.rb @@ -18,7 +18,10 @@ module Vagrant b = @env.boxes.find(argv[0]) raise Errors::BoxNotFound, :name => argv[0] if !b b.destroy - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/box_repackage.rb b/lib/vagrant/command/box_repackage.rb index a9f161cfc..f4357002e 100644 --- a/lib/vagrant/command/box_repackage.rb +++ b/lib/vagrant/command/box_repackage.rb @@ -18,7 +18,10 @@ module Vagrant b = @env.boxes.find(argv[0]) raise Errors::BoxNotFound, :name => argv[0] if !b b.repackage - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/destroy.rb b/lib/vagrant/command/destroy.rb index 771f6d57c..abbc13001 100644 --- a/lib/vagrant/command/destroy.rb +++ b/lib/vagrant/command/destroy.rb @@ -55,7 +55,10 @@ module Vagrant vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/halt.rb b/lib/vagrant/command/halt.rb index b938d99de..ce32a92d4 100644 --- a/lib/vagrant/command/halt.rb +++ b/lib/vagrant/command/halt.rb @@ -30,7 +30,10 @@ module Vagrant vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/init.rb b/lib/vagrant/command/init.rb index f1f18adb6..37c44737d 100644 --- a/lib/vagrant/command/init.rb +++ b/lib/vagrant/command/init.rb @@ -31,7 +31,10 @@ module Vagrant @env.ui.info(I18n.t("vagrant.commands.init.success"), :prefix => false) - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/package.rb b/lib/vagrant/command/package.rb index d379913a3..a8c5f7180 100644 --- a/lib/vagrant/command/package.rb +++ b/lib/vagrant/command/package.rb @@ -39,7 +39,10 @@ module Vagrant else package_target(argv[0], options) end - end + + # Success, exit status 0 + 0 + end protected diff --git a/lib/vagrant/command/provision.rb b/lib/vagrant/command/provision.rb index e9bf51ced..86bf337c9 100644 --- a/lib/vagrant/command/provision.rb +++ b/lib/vagrant/command/provision.rb @@ -30,7 +30,10 @@ module Vagrant vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/reload.rb b/lib/vagrant/command/reload.rb index f9ed9e3fa..be675e445 100644 --- a/lib/vagrant/command/reload.rb +++ b/lib/vagrant/command/reload.rb @@ -29,7 +29,10 @@ module Vagrant vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/resume.rb b/lib/vagrant/command/resume.rb index cd0ab3d1c..e810d666e 100644 --- a/lib/vagrant/command/resume.rb +++ b/lib/vagrant/command/resume.rb @@ -24,7 +24,10 @@ module Vagrant vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/ssh.rb b/lib/vagrant/command/ssh.rb index 0df1b3007..42384ae2b 100644 --- a/lib/vagrant/command/ssh.rb +++ b/lib/vagrant/command/ssh.rb @@ -53,7 +53,10 @@ module Vagrant ssh_connect(vm, opts) end end - end + + # Success, exit status 0 + 0 + end protected diff --git a/lib/vagrant/command/ssh_config.rb b/lib/vagrant/command/ssh_config.rb index c0474a0c1..5d406d0e9 100644 --- a/lib/vagrant/command/ssh_config.rb +++ b/lib/vagrant/command/ssh_config.rb @@ -42,7 +42,10 @@ module Vagrant template = "commands/ssh_config/config" safe_puts(Util::TemplateRenderer.render(template, variables)) end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/status.rb b/lib/vagrant/command/status.rb index 52a3de8b4..94bb12628 100644 --- a/lib/vagrant/command/status.rb +++ b/lib/vagrant/command/status.rb @@ -27,7 +27,10 @@ module Vagrant :states => results.join("\n"), :message => I18n.t("vagrant.commands.status.#{state}")), :prefix => false) - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/suspend.rb b/lib/vagrant/command/suspend.rb index 21054b990..9be41ef9e 100644 --- a/lib/vagrant/command/suspend.rb +++ b/lib/vagrant/command/suspend.rb @@ -24,7 +24,10 @@ module Vagrant vm.ui.info I18n.t("vagrant.commands.common.vm_not_created") end end - end + + # Success, exit status 0 + 0 + end end end end diff --git a/lib/vagrant/command/up.rb b/lib/vagrant/command/up.rb index abc10048e..5dfddfe82 100644 --- a/lib/vagrant/command/up.rb +++ b/lib/vagrant/command/up.rb @@ -31,7 +31,10 @@ module Vagrant vm.up(options) end end - end + + # Success, exit status 0 + 0 + end end end end