Repository navigation
shell: emit a PowerShell assignment from export_value - #24010
Merged
Merged
Conversation
MikeMcQuaid
enabled auto-merge
September 17, 2026 07:07
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
force-pushed
the
fix/pwsh-export-value
branch
from
September 17, 2026 07:25
4c8a4c5 to
fd7f688
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
brew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?The follow-up I named in #23996.
Utils::Shell.export_valuehas a branch for every shell it recognises exceptpwsh, which falls off the end of thecaseand returnsnil.Reproduce:
cmd/--env.rb:54doesputs Utils::Shell.export_value(...), sonilprints an empty line. The samenilreachescaveats.rb:98-123, so a formula that wantsLDFLAGS/CPPFLAGS/PKG_CONFIG_PATHset prints "For compilers to find x you may need to set:" followed by blank lines, for anyone whoseSHELLis pwsh.Same value, five shells, before this change:
export_value("LDFLAGS", "-L…/lib")export LDFLAGS="-L…/lib"set -gx LDFLAGS "-L…/lib"setenv LDFLAGS -L…/lib;nilpwsh is not an unsupported shell here:
from_pathaccepts it,profilemaps it,set_variable_in_profileandprepend_path_in_profileboth emit for it, andbrew shellenv pwshalready works.export_valueis the one function that does not.The emitted form is
$env:NAME = 'value', matchingset_variable_in_profile, and quoting goes through the existingpwsh_quotesoit'sbecomes'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:
export_valuehad no spec coverage at all, for any shell. This adds three: the pwsh line, pwsh quoting, and a bash case as a control. Reverting onlyutils/shell.rbfails exactly the two pwsh examples and leaves the bash one green.brew lgtmis green, andbrew tests --only=caveatsand--only=cmd/--envpass, 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.