Skip to content

Conversation

@MikeMcQuaid
Copy link
Member

Let's just use the simplest method (that we use in the installer) to detect the shell.

Let's just tell users to set the shell name explicitly if this detection is wrong.

This is done by many other tools and avoids us fighting with stupid checks that don't work reliably or speedily under sandboxes etc.

Fixes #21284

Copy link
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

This pull request simplifies shell detection in the brew shellenv command by replacing platform-specific detection methods (lsof on macOS, ps elsewhere) with a simpler ${SHELL##*/} approach that extracts the shell name from the $SHELL environment variable. The documentation is updated across all files to recommend explicitly specifying the shell name parameter and to provide clear examples.

  • Simplifies shell detection by using ${SHELL##*/} instead of lsof/ps commands
  • Updates documentation to recommend explicit shell specification with examples
  • Adds caveat that automatic detection may not always be correct

Reviewed changes

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

File Description
Library/Homebrew/cmd/shellenv.sh Simplified shell detection logic to use ${SHELL##*/} parameter expansion
Library/Homebrew/cmd/shellenv.rb Updated command documentation with explicit shell examples and detection caveat
docs/Manpage.md Updated man page documentation with explicit shell examples and improved guidance
manpages/brew.1 Updated generated man page with corresponding documentation changes

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

MikeMcQuaid and others added 3 commits January 8, 2026 10:37
Let's just use the simplest method (that we use in the installer) to
detect the shell.

Let's just tell users to set the shell name explicitly if this
detection is wrong.
This is done by many other tools and avoids us fighting with stupid
checks that don't work reliably or speedily under sandboxes etc.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
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

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


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

@MikeMcQuaid MikeMcQuaid enabled auto-merge January 8, 2026 10:58
@maschwenk
Copy link
Contributor

thank you @MikeMcQuaid 🙏🏼

@MikeMcQuaid MikeMcQuaid added this pull request to the merge queue Jan 8, 2026
Merged via the queue into main with commit 3b90473 Jan 8, 2026
44 checks passed
@MikeMcQuaid MikeMcQuaid deleted the improve_shellenv branch January 8, 2026 17:43
@simono
Copy link
Contributor

simono commented Jan 8, 2026

Whoa, this broke my setup really hard. I use fish and had /opt/homebrew/bin/brew shellenv | source in my fish config. After this change shellenv didn't detect fish anymore but zsh. Then my whole fish setup exploded 🤯
With /opt/homebrew/bin/brew shellenv fish | source it works now.

Might be worth to mention this somewhere very explicitly 😄

Btw: Thanks for your work! ❤️

simono added a commit to simono/dotfiles that referenced this pull request Jan 8, 2026
pricci1 added a commit to pricci1/packages that referenced this pull request Jan 9, 2026
Brew Homebrew/brew#21374 changed how shell is detected. Now fish is not detected in this contexts and `brew shellenv` outputs bash syntax, breaking fish initialization
pricci1 added a commit to pricci1/brew that referenced this pull request Jan 11, 2026
Brew Homebrew/brew#21374 changed how shell is detected. Now fish is not detected in this contexts and `brew shellenv` outputs bash syntax, breaking fish initialization.
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.

new lsof usage is extremely slow in Cursor/VSCode integrated terminal

5 participants