From 548316ecc827a1637122b3addc91f9f9fa92011c Mon Sep 17 00:00:00 2001 From: Adrian Ho Date: Sat, 6 Mar 2021 21:07:33 +0800 Subject: [PATCH] --prefix: shortlist only formulae --- Library/Homebrew/prefix.sh | 9 ++++++--- Library/Homebrew/test/cmd/--prefix_spec.rb | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/prefix.sh b/Library/Homebrew/prefix.sh index 5da567bd6c..1bc902b6d9 100644 --- a/Library/Homebrew/prefix.sh +++ b/Library/Homebrew/prefix.sh @@ -17,10 +17,13 @@ homebrew-prefix() { [ -z "$formula" ] && echo "$HOMEBREW_PREFIX" && return 0 local formula_path - if [ -f "$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/${formula}.rb" ]; then - formula_path="$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/${formula}.rb" + if [ -f "$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb" ]; then + formula_path="$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb" else - formula_path="$(find "$HOMEBREW_REPOSITORY/Library/Taps" -name "${formula}.rb" -print -quit)" + formula_path="$( + shopt -s nullglob + echo "$HOMEBREW_REPOSITORY/Library/Taps"/*/*/{Formula/,HomebrewFormula/,}"${formula}.rb" + )" fi [ -z "$formula_path" ] && return 1 diff --git a/Library/Homebrew/test/cmd/--prefix_spec.rb b/Library/Homebrew/test/cmd/--prefix_spec.rb index 23963e50e1..44a4244667 100644 --- a/Library/Homebrew/test/cmd/--prefix_spec.rb +++ b/Library/Homebrew/test/cmd/--prefix_spec.rb @@ -21,7 +21,7 @@ describe "brew --prefix" do end it "errors if the given Formula doesn't exist", :integration_test do - expect { brew "--prefix", "--installed", "nonexistent" } + expect { brew "--prefix", "nonexistent" } .to output(/No available formula/).to_stderr .and not_to_output.to_stdout .and be_a_failure