Fix generated PowerShell init script - #7070
Conversation
| ### cat root/opam-init/init.ps1 | ||
| if Test-Path "${BASEDIR}/root/opam-init/variables.ps1" { . "${BASEDIR}/root/opam-init/variables.ps1" *> $null } | ||
| if (Test-Path "${BASEDIR}/root/opam-init/variables.ps1") { . "${BASEDIR}/root/opam-init/variables.ps1" *> $null } | ||
| ### powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Bypass -File root/opam-init/init.ps1 |
There was a problem hiding this comment.
neat idea to at least test the syntax, it should probably be done for every shell we support (you're welcome to do it but it's not strictly necessary for this PR so no pressure)
There was a problem hiding this comment.
I tried to add them but I'm not sure if it works. Would you approve the workflow and test it?
There was a problem hiding this comment.
The workflow failed and I guess that's due to an upstream problem which has been fixed. I updated the branch. Would you approve the workflow again? Thanks
There was a problem hiding this comment.
For the record, you can open a PR on your own fork and enable GitHub Action on it, if you want to debug something. This way i don't have to approve it every time
There was a problem hiding this comment.
Thanks for the tip. The checks succeeded. If maintainers do not have further comments, I believe this PR is now ready to merge.
Problem
Since #5864, opam has generated the following PowerShell:
PowerShell requires parentheses around an
ifcondition and rejects thisscript with:
Fix
Generate valid PowerShell syntax:
The Windows reftest now executes the generated script using Windows
PowerShell, ensuring future syntax errors fail the test.
Testing
The generated script was also executed successfully with Windows PowerShell
5.1 and PowerShell 7.