lib/bolt/shell/bash.rb in bolt-3.19.0 vs lib/bolt/shell/bash.rb in bolt-3.20.0

- old
+ new

@@ -98,11 +98,11 @@ exec_args = [path, *arguments] interpreter = select_interpreter(script, target.options['interpreters']) # Only use interpreter if script_interpreter config is enabled if options[:script_interpreter] && interpreter - exec_args.unshift(interpreter) + exec_args.unshift(interpreter).flatten! logger.trace("Running '#{script}' using '#{interpreter}' interpreter") end output = execute(exec_args, environment: options[:env_vars], sudoable: true) Bolt::Result.for_command(target, @@ -252,11 +252,11 @@ def make_wrapper_stringio(task_path, stdin, interpreter = nil) if interpreter StringIO.new(<<~SCRIPT) #!/bin/sh - '#{interpreter}' '#{task_path}' <<'EOF' + #{Array(interpreter).map { |word| "'#{word}'" }.join(' ')} '#{task_path}' <<'EOF' #{stdin} EOF SCRIPT else StringIO.new(<<~SCRIPT) @@ -333,14 +333,10 @@ end # Returns string with the interpreter conditionally prepended def inject_interpreter(interpreter, command) if interpreter - if command.is_a?(Array) - command.unshift(interpreter) - else - command = [interpreter, command] - end + command = Array(command).unshift(interpreter).flatten end command.is_a?(String) ? command : Shellwords.shelljoin(command) end