diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b06d34cc..fee78fa38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ would be port collisions. [GH-602] - `vagrant ssh -c` will now exit with the same exit code as the command run. [GH-598] + - `vagrant ssh -c` will not send stderr to stderr and stdout to stdout + on the host machine, instead of all output to stdout. ## 0.8.10 (December 10, 2011) diff --git a/lib/vagrant/command/ssh.rb b/lib/vagrant/command/ssh.rb index 77b2deed4..7be4f020f 100644 --- a/lib/vagrant/command/ssh.rb +++ b/lib/vagrant/command/ssh.rb @@ -48,9 +48,16 @@ module Vagrant if type == :exit_status exit_status = data.to_i else + # Determine the proper channel to send the output onto depending + # on the type of data we are receiving. + channel = type == :stdout ? :out : :error + # 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) + vm.ui.info(data.to_s, + :prefix => false, + :new_line => false, + :channel => channel) end end end diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index 69019a0b0..a1b3d4727 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -80,7 +80,7 @@ module Vagrant # Determine the proper IO channel to send this message # to based on the type of the message - channel = type == :error ? $stderr : $stdout + channel = type == :error || opts[:channel] == :error ? $stderr : $stdout # Output! channel.send(printer, format_message(type, message, opts)) diff --git a/test/acceptance/ssh_test.rb b/test/acceptance/ssh_test.rb index 698c79efc..84e4fd72a 100644 --- a/test/acceptance/ssh_test.rb +++ b/test/acceptance/ssh_test.rb @@ -38,7 +38,7 @@ describe "vagrant ssh" do result = execute("vagrant", "ssh", "-c", "foooooooooo") result.exit_code.should == 127 - #result.stderr.should =~ /foooooooooo: command not found/ + result.stderr.should =~ /foooooooooo: command not found/ end # TODO: