audit: don't split shell commands when using a glob pattern

Without this, `brew audit <some formula>` may ask people to change:

    system "./script.sh foo-*"

into:

    system "./script.sh", "foo-*"

These are not the same. In the first example the shell expansion occurs
while it doesn’t in the second one, breaking the build.

Closes Homebrew/homebrew#38540.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Baptiste Fontaine 2015-04-11 10:22:49 +02:00 committed by Mike McQuaid
parent 9c46e4be0a
commit 8363b35216

View File

@ -720,7 +720,7 @@ class FormulaAuditor
if @strict if @strict
if line =~ /system (["'][^"' ]*(?:\s[^"' ]*)+["'])/ if line =~ /system (["'][^"' ]*(?:\s[^"' ]*)+["'])/
bad_system = $1 bad_system = $1
unless %w[| < > & ;].any? { |c| bad_system.include? c } unless %w[| < > & ; *].any? { |c| bad_system.include? c }
good_system = bad_system.gsub(" ", "\", \"") good_system = bad_system.gsub(" ", "\", \"")
problem "Use `system #{good_system}` instead of `system #{bad_system}` " problem "Use `system #{good_system}` instead of `system #{bad_system}` "
end end