list.sh: only show headings when there are items to show#22123
Merged
ZhongRuoyu merged 2 commits intomainfrom May 3, 2026
Merged
list.sh: only show headings when there are items to show#22123ZhongRuoyu merged 2 commits intomainfrom
ZhongRuoyu merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the fast-path brew list shell implementation (list.sh) to better match the Ruby implementation by only printing section headings when there are items to display.
Changes:
- Move the “Formulae” heading to only print when the formula list output is non-empty.
- Move the “Casks” heading to only print when the cask list output is non-empty.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a46f556 to
27a2654
Compare
If there are no formulae or casks to show, then don't show the "Formulae" or "Casks" headings. This used to be the case when there was only the Ruby implementation, and continues to be the case when the Ruby implementation is used [^1], so we should maintain the consistency. [^1]: https://github.com/Homebrew/brew/blob/4a95077682ae5f342cf60ff181ebbcfb03d49117/Library/Homebrew/cmd/list.rb#L162-L170
27a2654 to
3bda513
Compare
carlocab
approved these changes
May 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If there are no formulae or casks to show, then don't show the "Formulae" or "Casks" headings. This used to be the case when there was only the Ruby implementation, and continues to be the case when the Ruby implementation is used 1, so we should maintain the consistency.
brew lgtm(style, typechecking and tests) with your changes locally?Footnotes
https://github.com/Homebrew/brew/blob/4a95077682ae5f342cf60ff181ebbcfb03d49117/Library/Homebrew/cmd/list.rb#L162-L170 ↩