diff options
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/requirement.rb | 4 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/Library/Homebrew/requirement.rb b/Library/Homebrew/requirement.rb index 91eedd72d..0aa4ed78d 100644 --- a/Library/Homebrew/requirement.rb +++ b/Library/Homebrew/requirement.rb @@ -134,6 +134,10 @@ class Requirement super(cmd, ORIGINAL_PATHS.join(File::PATH_SEPARATOR)) end + def which_all(cmd) + super(cmd, ORIGINAL_PATHS.join(File::PATH_SEPARATOR)) + end + class << self include BuildEnvironmentDSL diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 50e226faa..a709827a5 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -361,6 +361,19 @@ def which(cmd, path = ENV["PATH"]) nil end +def which_all(cmd, path = ENV["PATH"]) + path.split(File::PATH_SEPARATOR).map do |p| + begin + pcmd = File.expand_path(cmd, p) + rescue ArgumentError + # File.expand_path will raise an ArgumentError if the path is malformed. + # See https://github.com/Homebrew/homebrew/issues/32789 + next + end + Pathname.new(pcmd) if File.file?(pcmd) && File.executable?(pcmd) + end.compact.uniq +end + def which_editor editor = ENV.values_at("HOMEBREW_EDITOR", "VISUAL", "EDITOR").compact.first return editor unless editor.nil? |
