Skip to content

refactor "export pwsh" to resolve issue #1254 #1448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

LookoutHill
Copy link
Contributor

This pull request should resolve any issues related to #1254 by building on pull request #1255. By enforcing envvar creation of the form ${env:key} = 'value' and envvar removal with Remove-Item -LiteralPath 'env:key', these forms minimize interpolation of the keys and values and this minimizes special character processing which was split into 3 functions to address ${env:key}, 'value', and 'env:key' separately. All of these changes required changing the export line of the PowerShell hook from $export = /<PATH TO DIRENV>/direnv export pwsh; to $export = (/<PATH TO DIRENV>/direnv export pwsh) -join [Environment]::NewLine;. Some additional character value names were added to internal/cmd/shell_bash.go to support the new special character processing.

@zimbatm
Copy link
Member

zimbatm commented Jun 14, 2025

@BlackHoleFox do you want to review this PR? Sorry I didn't get back to yours before.

@zimbatm
Copy link
Member

zimbatm commented Jun 14, 2025

@bamsammich maybe as well?

We don't have really good PowerShell tests.

@BlackHoleFox
Copy link

@zimbatm I ran out of energy to continue my original PR, so not all on you :)

Saw a few things in the changeset I obviously missed doing in my attempt and nothing looks immediately incorrect.

Not really a Go expert at the end of the day but I built this branch on my pwsh macbook setup and tried my original reproducer. Everything seems to be working the same or better as my past attempt so this gets the +1 from me:
image

@zimbatm zimbatm merged commit e65f716 into direnv:master Jun 17, 2025
14 checks passed
@zimbatm
Copy link
Member

zimbatm commented Jun 17, 2025

sweet, thanks for testing!

@zimbatm
Copy link
Member

zimbatm commented Jun 17, 2025

and thanks @LookoutHill for getting this over the line!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants