From b4fc4acc09c469407db4ec41dd427f554656cc2d Mon Sep 17 00:00:00 2001 From: Josh Hagins <hagins.josh@gmail.com> Date: Mon, 17 Oct 2016 23:46:23 -0400 Subject: [PATCH] hbc/locations: arg is file only if absolute or .rb file Handle the case when an argument passed to `brew cask` is both the name of a Cask and a non-Cask file in the current working directory. Fixes https://github.com/caskroom/homebrew-cask/issues/25611. --- Library/Homebrew/cask/lib/hbc/locations.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/locations.rb b/Library/Homebrew/cask/lib/hbc/locations.rb index c763b974b4..f1c7d138be 100644 --- a/Library/Homebrew/cask/lib/hbc/locations.rb +++ b/Library/Homebrew/cask/lib/hbc/locations.rb @@ -133,9 +133,8 @@ module Hbc def path(query) query_path = Pathname.new(query) - if query_path.exist? || query_path.absolute? - return query_path - end + return query_path if query_path.absolute? + return query_path if query_path.exist? && query_path.extname == ".rb" query_without_extension = query.sub(%r{\.rb$}i, "") -- GitLab