From 6721d8e9642961a39c5cc73343c487cdf922bff0 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 15 Apr 2014 19:31:13 -0700 Subject: [PATCH] communicators/ssh: just use Ruby 2.0 features --- plugins/communicators/ssh/communicator.rb | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index daa6333b8..eb0686648 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -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