Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
199 stars 29 forks source link

Add PowerShell version detection #110

Closed vagreargnatry closed 1 year ago

vagreargnatry commented 1 year ago

Different versions of PowerShell require different commands.

https://github.com/Eugleo/magic-racket/pull/95 https://github.com/Eugleo/magic-racket/issues/94

I apologize for the diff caused by the code formatting.

jryans commented 1 year ago

Thanks for working on this! Do you happen to know of any reference that explains the PowerShell quoting rules and gives more info on when they were changed...? I'd like to understand what they've changed in a bit more detail first.

I tried some basic searching, but I didn't see an obvious article to read, so that's why I'm wondering if you might have one... Thanks! 🙂

vagreargnatry commented 1 year ago

I found an answer, hope this can help you. https://stackoverflow.com/a/69844230

The test results on my computer (Windows 11 22H2) are:

  1. In PowerShell 7.3.5, the following two commands can work:
    racket --repl --eval '(enter! (file "c:/Users/omenl/Desktop/chez-playground/sample2.rkt"))'
    racket --repl --eval "(enter! (file `"c:/Users/omenl/Desktop/chez-playground/sample2.rkt`"))"
  2. In Powershell 5.1.22621.1778, only this command can work:
    racket --repl --eval '(enter! (file \"c:/Users/omenl/Desktop/chez-playground/sample2.rkt\"))'
jryans commented 1 year ago

Thanks for the additional info! The answer you linked suggests that the PowerShell 5 command is called powershell, while the PowerShell 7 command is called pwsh. Does that match the state on your system?

If it does, perhaps the quoting rules could differ based on the command name? I might be missing something though, as I don't use PowerShell myself.

vagreargnatry commented 1 year ago

Yes, this match the state on my machine. Using command names to differentiate versions is better than using child_process.

jryans commented 1 year ago

I'm planning to publish a release with this fix in a few days or so, once the related issue https://github.com/Eugleo/magic-racket/issues/114 is also resolved.

jryans commented 1 year ago

0.6.6 has now been published with this change. Thanks again! 😄