Merge pull request #10800 from gromgit/prefix-fix

--prefix: shortlist only formulae
This commit is contained in:
Mike McQuaid 2021-03-11 10:41:27 +00:00 committed by GitHub
commit 5240afbbb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -17,10 +17,13 @@ homebrew-prefix() {
[ -z "$formula" ] && echo "$HOMEBREW_PREFIX" && return 0 [ -z "$formula" ] && echo "$HOMEBREW_PREFIX" && return 0
local formula_path local formula_path
if [ -f "$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/${formula}.rb" ]; then if [ -f "$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb" ]; then
formula_path="$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/${formula}.rb" formula_path="$HOMEBREW_REPOSITORY/Library/Taps/homebrew/homebrew-core/Formula/${formula}.rb"
else 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 fi
[ -z "$formula_path" ] && return 1 [ -z "$formula_path" ] && return 1

View File

@ -21,7 +21,7 @@ describe "brew --prefix" do
end end
it "errors if the given Formula doesn't exist", :integration_test do 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 .to output(/No available formula/).to_stderr
.and not_to_output.to_stdout .and not_to_output.to_stdout
.and be_a_failure .and be_a_failure