diff options
| author | Baptiste Fontaine | 2015-08-14 22:57:49 +0200 |
|---|---|---|
| committer | Baptiste Fontaine | 2015-08-16 17:03:05 +0200 |
| commit | c631fc30131bc429d0da60053c5169376a507aae (patch) | |
| tree | 74924c8c2750f562e4a1db3115499e9b0043a5f9 /Library/Homebrew | |
| parent | 6606c7b53b6dadfed821e36eaf3333893cd7ae4e (diff) | |
| download | brew-c631fc30131bc429d0da60053c5169376a507aae.tar.bz2 | |
which: don't fail on malformed paths in PATH
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/utils.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index a6c47b27a..1390db14e 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -244,7 +244,13 @@ end def which(cmd, path = ENV["PATH"]) path.split(File::PATH_SEPARATOR).each do |p| - pcmd = File.expand_path(cmd, 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 return Pathname.new(pcmd) if File.file?(pcmd) && File.executable?(pcmd) end nil |
