10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/bolt/transport/local/shell.rb', line 10
def execute(*command, options)
if options[:env]
env = options[:env].each_with_object({}) { |(k, v), h| h["PT_#{k}"] = v.to_s }
command = [env] + command
end
if options[:stdin]
stdout, stderr, rc = Open3.capture3(*command, stdin_data: options[:stdin])
else
stdout, stderr, rc = Open3.capture3(*command)
end
result_output = Bolt::Node::Output.new
result_output.stdout << stdout unless stdout.nil?
result_output.stderr << stderr unless stderr.nil?
result_output.exit_code = rc.to_i
result_output
end
|