Merge pull request #11956 from benpbolton/patch-1

Wrap mac 'brew info' multi-word service command parameters in single quotes
This commit is contained in:
Mike McQuaid 2021-09-07 19:43:06 +01:00 committed by GitHub
commit f5a4214a70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -37,7 +37,14 @@ class Caveats
if f.plist_manual || f.service?
command = if f.service?
f.service.command.join(" ")
f.service
.command
.map do |arg|
next arg unless arg.match?(/\s/)
# quote multi-word arguments
"'#{arg}'"
end.join(" ")
else
f.plist_manual
end

View File

@ -128,6 +128,20 @@ describe Caveats do
expect(caveats).to include("background service")
end
it "wraps multi-word service parameters" do
f = formula do
url "foo-1.0"
service do
run [bin/"nginx", "-g", "daemon off;"]
end
end
caveats = described_class.new(f).caveats
expect(f.service?).to eq(true)
expect(caveats).to include("#{f.bin}/nginx -g 'daemon off;'")
expect(caveats).to include("background service")
end
it "warns about brew failing under tmux" do
f = formula do
url "foo-1.0"