Skip to content

Strip login-shell startup noise via marker - #184

Merged
graeme merged 1 commit into
mainfrom
iterm-compat-issues
Sep 14, 2026
Merged

graeme merged 1 commit into
mainfrom
iterm-compat-issues

Conversation

@graeme

@graeme graeme commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator

Fixes #167
Closes #157

PR: Strip login shell startup noise from brew output

Summary

LoginShellBrewCommandRunner wraps every brew invocation in the user's login and interactive shell (-l -i) for parity with Terminal. Some shell configurations, notably iTerm2's shell integration, print banners or OSC escape sequences to stdout and stderr during startup, and that noise was leaking into brew's output and breaking JSON parsing and error display. This PR adds a marker based cutoff so only the real command output survives.

Changes

  • LoginShellBrewCommandRunner prints a unique marker to the output streams right before exec'ing brew, then strips everything up to and including that marker line from the buffered result.
  • For streamed output, LoginShellStartupGate filters live lines the same way, so the marker line and everything before it never reach the line observer.
  • The marker is announced on both stdout and stderr for pipe based output, and once for pseudo terminal output, matching how each channel is consumed.

Testing

  • LoginShellBrewCommandRunnerTests, in particular:
    • run strips shell startup noise from both streams, which reproduces the iTerm2 shell integration report: startup noise on both streams ahead of the real command output.
    • run filters the startup marker out of streamed lines, which covers the live streaming path.
    • removingStartupNoise cases covering marker present, absent, and as the last line.
  • Full swift test run for BrewCLI and BrewCLITests.

PR checklist

  • Have you followed this repository's contribution and workflow guidance?
  • Have you explained what changed and why this should land now?
  • Have you run relevant local checks for the changed scope?
  • Are changes scoped and free of unrelated modifications?

  • AI was used to generate or assist with generating this PR.
  • Claude Code was used to implement the marker based stripping, write the accompanying tests, and draft this description. Verified by running the unit test suite and by manually reproducing the original noise with iTerm2 shell integration enabled, confirming it no longer appears after the fix.

Wrap every brew invocation in the user's login+interactive shell (-l -i) for environment parity with Terminal, then print a unique marker to stdout/stderr right before execing brew and strip everything up through that marker line — so rc-file startup noise (banners, OSC sequences) never leaks into the command's real output.
@graeme
graeme requested a review from MikeMcQuaid September 14, 2026 12:29
@graeme

graeme commented Sep 14, 2026

Copy link
Copy Markdown
Collaborator Author

Fixes #167

@graeme
graeme merged commit a8036e1 into main Sep 14, 2026
11 checks passed
@graeme
graeme deleted the iterm-compat-issues branch September 14, 2026 12:48
@MilesTEG1

Copy link
Copy Markdown

Hello,
When should we expect a new BrewUI build that includes this fix?
Thanks a lot 🙏🏻

@edarchis

Copy link
Copy Markdown

Hello, When should we expect a new BrewUI build that includes this fix? Thanks a lot 🙏🏻

It's available and I confirm that it works now

brew update
brew upgrade homebrew-app

@rhomolka-tblock

This comment was marked as low quality.

@MikeMcQuaid

Copy link
Copy Markdown
Member

There will be a near infinite number of possible shell variants that break this app. Anything that isn't reported by multiple people will not be prioritised.

@Homebrew Homebrew locked as resolved and limited conversation to collaborators Sep 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stuck saying "Failed to decode JSON output."

5 participants