Skip to content

Commit

Permalink
Merge pull request #254 from thheinen/theinen/tm-fix-regression
Browse files Browse the repository at this point in the history
Fix quoting regression
  • Loading branch information
tpowell-progress authored Jan 15, 2025
2 parents d009fc2 + 686b52e commit 8966407
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/mixlib/shellout/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,14 @@ def __clean_array(*args)
# @param args [String] variable number of string arguments
# @return [String] merged string
#
def __join_whitespace(*args)
args.flatten.map do |arg|
arg.strip!
arg.include?(" ") ? sprintf('"%s"', arg) : arg
def __join_whitespace(*args, quote: false)
args.map do |arg|
if arg.is_a?(Array)
__join_whitespace(*arg, quote: arg.count > 1)
else
arg = arg.include?(" ") ? sprintf('"%s"', arg) : arg if quote
arg.strip
end
end.join(" ")
end

Expand All @@ -168,7 +172,7 @@ def __shell_out_command(*args, **options)
if options[:input]
command.concat "<<'COMMANDINPUT'\n"
command.concat __join_whitespace(options[:input])
command.concat "COMMANDINPUT\n"
command.concat "\nCOMMANDINPUT\n"
end
end

Expand Down

0 comments on commit 8966407

Please sign in to comment.