Skip to content

Accept one-key ask confirmations#22436

Merged
MikeMcQuaid merged 1 commit into
mainfrom
ask-single-key-confirmation
May 28, 2026
Merged

Accept one-key ask confirmations#22436
MikeMcQuaid merged 1 commit into
mainfrom
ask-single-key-confirmation

Conversation

@MikeMcQuaid
Copy link
Copy Markdown
Member

@MikeMcQuaid MikeMcQuaid commented May 28, 2026

  • Allow brew --ask prompts to proceed from y or Y.
  • Abort from n or N without waiting for a newline.
  • Treat Escape, Ctrl-D and Ctrl-C as quiet cancellation.
  • Reprompt after other keys so users choose explicitly.

  • 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? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you written new tests (excluding integration tests) for your changes? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) with your changes locally?

  • AI was used to generate or assist with generating this PR.

OpenAI Codex 5.5 xhigh with manual review and testing.


Copilot AI review requested due to automatic review settings May 28, 2026 08:25
@MikeMcQuaid MikeMcQuaid force-pushed the ask-single-key-confirmation branch from 6de37a0 to a412e73 Compare May 28, 2026 08:28
Copy link
Copy Markdown
Contributor

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

Switches the brew --ask confirmation prompt from line-buffered gets (requires Enter) to single-keypress getch, so a lone y/Y proceeds and n/N/Enter aborts without needing Return.

Changes:

  • Replace $stdin.gets with $stdin.getch in ask_input, drop the yes/no word forms, and update the invalid-input hint accordingly.
  • require "io/console" in install.rb to enable IO#getch.
  • Update existing ask specs to stub getch and add new specs covering y/Y accept and n/N decline single-key paths.

Reviewed changes

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

File Description
Library/Homebrew/install.rb Adds io/console require and rewrites the ask prompt loop to read a single character, accepting only y and treating blank/n as abort.
Library/Homebrew/test/cmd/install_spec.rb Updates the default-no test to stub getch, adds accept/decline single-char tests, and updates the no-TTY test to assert getch is not called.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Library/Homebrew/install.rb Outdated
Comment thread Library/Homebrew/test/cmd/install_spec.rb Outdated
@MikeMcQuaid MikeMcQuaid force-pushed the ask-single-key-confirmation branch from a412e73 to a17baa2 Compare May 28, 2026 08:33
- Allow `brew --ask` prompts to proceed from `y` or `Y`.
- Abort from `n` or `N` without waiting for a newline.
- Treat Escape, Ctrl-D and Ctrl-C as quiet cancellation.
- Reprompt after other keys so users choose explicitly.
@MikeMcQuaid MikeMcQuaid force-pushed the ask-single-key-confirmation branch from a17baa2 to e49b5ca Compare May 28, 2026 08:35
@MikeMcQuaid MikeMcQuaid enabled auto-merge May 28, 2026 08:46
@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue May 28, 2026
Merged via the queue into main with commit 4b32d68 May 28, 2026
37 checks passed
@MikeMcQuaid MikeMcQuaid deleted the ask-single-key-confirmation branch May 28, 2026 09:15
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.

3 participants