Skip to content

Conversation

ZhongRuoyu
Copy link
Member

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Some Bash commands don't recognize global options like --help, --debug, etc. For --help, we fix this in brew.sh by redirecting to the Ruby code path when --help is detected. For the remaining global options, we add handling for them in the respective shell commands.

@Copilot Copilot AI review requested due to automatic review settings October 18, 2025 17:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds handling for global options (e.g. --help, --debug, --quiet, --verbose) in Bash command scripts so they recognize and properly process help and other flags rather than ignoring or misinterpreting them.

  • Early global help detection moved earlier in brew.sh and guarded command dispatch logic with HOMEBREW_HELP.
  • Added filtering of global flags in several Bash command handlers (which-formula.sh, --repository.sh) and a wrapper alias function in --version.sh.
  • Adjusted shellenv.sh argument parsing to use a case statement for first argument classification.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Library/Homebrew/utils/ruby.sh Prevents early return for vendor-install when help is requested.
Library/Homebrew/cmd/which-formula.sh Skips global verbosity/debug flags during argument parsing.
Library/Homebrew/cmd/shellenv.sh Rewrites first-argument handling via case to recognize global flags.
Library/Homebrew/cmd/--version.sh Adds alias function for command name with leading dashes.
Library/Homebrew/cmd/--repository.sh Filters out global flags before processing tap arguments.
Library/Homebrew/brew.sh Moves global help detection earlier and gates command groups; alters version dispatch condition.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ZhongRuoyu ZhongRuoyu force-pushed the bash-cmd-global-options branch from 63f7ac1 to c0e00aa Compare October 18, 2025 17:56
Some Bash commands don't recognize global options like --help, --debug,
etc. For --help, we fix this in brew.sh by redirecting to the Ruby
code path when --help is detected. For the remaining global options, we
add handling for them in the respective shell commands.
@ZhongRuoyu ZhongRuoyu force-pushed the bash-cmd-global-options branch from c0e00aa to bd0ad8d Compare October 18, 2025 18:23
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR but I'm not sure this is an improvement, sorry 😭. --help will be dramatically slower than these various Bash commands and we're having to add net 25 lines for something no users seem to have complained about along with a bunch of nesting/checks scattered around where it's not obvious when/why/how they will be added/removed in future. I'm open to other approaches, though.

@ZhongRuoyu ZhongRuoyu marked this pull request as draft October 19, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants