communicators/ssh: just use Ruby 2.0 features

This commit is contained in:
Mitchell Hashimoto 2014-04-15 19:31:13 -07:00
parent c220bfc27d
commit 6721d8e964
1 changed files with 15 additions and 2 deletions

View File

@ -170,7 +170,12 @@ module VagrantPlugins
stdout = ""
stderr = ""
exit_status = connect do |connection|
shell_execute(connection, command, opts[:sudo], opts[:shell]) do |type, data|
shell_opts = {
sudo: opts[:sudo],
shell: opts[:shell],
}
shell_execute(connection, command, **shell_opts) do |type, data|
if type == :stdout
stdout += data
elsif type == :stderr
@ -390,7 +395,15 @@ module VagrantPlugins
end
# Executes the command on an SSH connection within a login shell.
def shell_execute(connection, command, sudo=false, shell=nil)
def shell_execute(connection, command, **opts)
opts = {
sudo: false,
shell: nil
}.merge(opts)
sudo = opts[:sudo]
shell = opts[:shell]
@logger.info("Execute: #{command} (sudo=#{sudo.inspect})")
exit_status = nil