From d47517f635001088fb1fb7bf43231b1fd5168d3b Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 20 May 2022 01:41:26 +0100 Subject: [PATCH] exceptions: handle backslash in args for BuildError --- Library/Homebrew/exceptions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 0a5526a5f..9dbb89449 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -479,7 +479,7 @@ class BuildError < RuntimeError @cmd = cmd @args = args @env = env - pretty_args = Array(args).map { |arg| arg.to_s.gsub " ", "\\ " }.join(" ") + pretty_args = Array(args).map { |arg| arg.to_s.gsub(/[\\ ]/, "\\\\\\0") }.join(" ") super "Failed executing: #{cmd} #{pretty_args}".strip end