G
YouTube TikTok Games
Skip to content

shell: emit a PowerShell assignment from export_value - #24010

Merged
MikeMcQuaid merged 2 commits into
Homebrew:mainfrom
rawsun007:fix/pwsh-export-value
Sep 17, 2026
Merged

MikeMcQuaid merged 2 commits into
Homebrew:mainfrom
rawsun007:fix/pwsh-export-value

Conversation

@rawsun007

Copy link
Copy Markdown
Contributor

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

The follow-up I named in #23996. Utils::Shell.export_value has a branch for every shell it recognises except pwsh, which falls off the end of the case and returns nil.

Reproduce:

$ brew --env --shell=pwsh
                      # twelve blank lines, exit 0
$ brew --env --shell=fish
set -gx CC "clang"
...

cmd/--env.rb:54 does puts Utils::Shell.export_value(...), so nil prints an empty line. The same nil reaches caveats.rb:98-123, so a formula that wants LDFLAGS/CPPFLAGS/PKG_CONFIG_PATH set prints "For compilers to find x you may need to set:" followed by blank lines, for anyone whose SHELL is pwsh.

Same value, five shells, before this change:

shell export_value("LDFLAGS", "-L…/lib")
bash, zsh export LDFLAGS="-L…/lib"
fish set -gx LDFLAGS "-L…/lib"
tcsh setenv LDFLAGS -L…/lib;
pwsh nil

pwsh is not an unsupported shell here: from_path accepts it, profile maps it, set_variable_in_profile and prepend_path_in_profile both emit for it, and brew shellenv pwsh already works. export_value is the one function that does not.

The emitted form is $env:NAME = 'value', matching set_variable_in_profile, and quoting goes through the existing pwsh_quote so it's becomes 'it''s'. That helper and this exact string shape were verified against PowerShell 7.4.6 in #23996; I did not re-run a live shell for this change.

After:

$ brew --env --shell=pwsh
$env:CC = 'clang'
$env:CXX = 'clang++'
$env:MAKEFLAGS = '-j10'

export_value had no spec coverage at all, for any shell. This adds three: the pwsh line, pwsh quoting, and a bash case as a control. Reverting only utils/shell.rb fails exactly the two pwsh examples and leaves the bash one green. brew lgtm is green, and brew tests --only=caveats and --only=cmd/--env pass, since a changed-files run does not cover the callers.

AI disclosure: written by Claude Opus 5 in Claude Code on my machine. I have not read the diff line by line myself yet, so the last box stays unticked; I answer review comments myself, and no commit here is attributed to an AI.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Every other shell returns a line; pwsh fell through the case and
returned nil. `brew --env --shell=pwsh` printed one blank line per
variable, and a formula's caveats printed "you may need to set:"
followed by blanks, for anyone whose SHELL is pwsh.

`from_path`, `profile`, `set_variable_in_profile` and
`prepend_path_in_profile` all handle pwsh already, as does
`brew shellenv pwsh`.
auto-merge was automatically disabled September 17, 2026 07:25

Head branch was pushed to by a user without write access

@rawsun007
rawsun007 force-pushed the fix/pwsh-export-value branch from 4c8a4c5 to fd7f688 Compare September 17, 2026 07:25
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Sep 17, 2026
Merged via the queue into Homebrew:main with commit 60c85d3 Sep 17, 2026
51 checks passed
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