`vagrant ssh -c` will now exit with the same exit status of the command [GH-598]
This commit is contained in:
parent
72b249fd19
commit
e07280593d
|
@ -24,6 +24,8 @@
|
|||
- "--no-provision" once again works for certain commands. [GH-591]
|
||||
- Resuming a VM from a saved state will show an error message if there
|
||||
would be port collisions. [GH-602]
|
||||
- `vagrant ssh -c` will now exit with the same exit code as the command
|
||||
run. [GH-598]
|
||||
|
||||
## 0.8.10 (December 10, 2011)
|
||||
|
||||
|
|
|
@ -40,16 +40,23 @@ module Vagrant
|
|||
protected
|
||||
|
||||
def ssh_execute(vm, command=nil)
|
||||
exit_status = 0
|
||||
|
||||
@logger.debug("Executing command: #{command}")
|
||||
vm.ssh.execute do |ssh|
|
||||
ssh.exec!(command) do |channel, type, data|
|
||||
if type != :exit_status
|
||||
if type == :exit_status
|
||||
exit_status = data.to_i
|
||||
else
|
||||
# Print the SSH output as it comes in, but don't prefix it and don't
|
||||
# force a new line so that the output is properly preserved
|
||||
vm.ui.info(data.to_s, :prefix => false, :new_line => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Exit with the exit status we got from executing the command
|
||||
exit exit_status
|
||||
end
|
||||
|
||||
def ssh_connect(vm)
|
||||
|
|
|
@ -32,8 +32,13 @@ describe "vagrant ssh" do
|
|||
assert_execute("vagrant", "init")
|
||||
assert_execute("vagrant", "up")
|
||||
|
||||
result = assert_execute("vagrant", "ssh", "-c", "echo foo")
|
||||
result = execute("vagrant", "ssh", "-c", "echo foo")
|
||||
result.exit_code.should == 0
|
||||
result.stdout.should == "foo\n"
|
||||
|
||||
result = execute("vagrant", "ssh", "-c", "foooooooooo")
|
||||
result.exit_code.should == 127
|
||||
#result.stderr.should =~ /foooooooooo: command not found/
|
||||
end
|
||||
|
||||
# TODO:
|
||||
|
|
Loading…
Reference in New Issue