communicators/ssh: just use Ruby 2.0 features
This commit is contained in:
parent
c220bfc27d
commit
6721d8e964
|
@ -170,7 +170,12 @@ module VagrantPlugins
|
||||||
stdout = ""
|
stdout = ""
|
||||||
stderr = ""
|
stderr = ""
|
||||||
exit_status = connect do |connection|
|
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
|
if type == :stdout
|
||||||
stdout += data
|
stdout += data
|
||||||
elsif type == :stderr
|
elsif type == :stderr
|
||||||
|
@ -390,7 +395,15 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
# Executes the command on an SSH connection within a login shell.
|
# 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})")
|
@logger.info("Execute: #{command} (sudo=#{sudo.inspect})")
|
||||||
exit_status = nil
|
exit_status = nil
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue