-
Notifications
You must be signed in to change notification settings - Fork 510
Resolve $Linux error #1235
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
Resolve $Linux error #1235
Conversation
@dsolodow you're on FIRE🔥 today. This looks fine to me although I'm not sure if What you could do is take advantage of the $IsWindows variable in PSCore. If it's Just a thought. |
@tylerl0706 - good point. I had originally thought about doing something with psversiontable (psedition and platform) but it was going to be fuglier. I didn't know about the $IsWindows as I've not dipped my toes much into PSCore yet. It would be easy enough to switch over if that's preferred by the team. |
Was going to say |
So I'm happy with either too |
scripts/Install-VSCode.ps1
Outdated
@@ -129,7 +131,7 @@ param( | |||
[switch]$LaunchWhenDone | |||
) | |||
|
|||
if (!($IsLinux -or $IsOSX)) { | |||
if ($env:windir -ne $null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this kind of test, I usually use if (($PSVersionTable.PSVersion.Major -le 5) -or $IsWindows) {
i.e. if the platform is <= v5 then it is Windows. If it is v6 or higher then $IsWindows
will be set appropriately. But there are several different ways to do this check that is valid across versions & platforms.
I prefer the above test because it uses PowerShell built-in variables. Env vars are controlled by the user and there is nothing stopping a Linux/macOS user from defining a windir
env var.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that seems like the right way to test this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep makes sense. The bug was opened because of StrictMode and I think what Keith said should play nice with it as well.
Change test for "isWindows"
That makes sense; fewer opportunities for someone to do something wonky in their environment and break it. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
merge time 😎 |
This resolves #996.
Tested on:
Windows 10 x64 Education Build 17127 (Windows PowerShell 5.1)
Windows 10 x64 Education Build 17127 (PowerShell Core 6.0.2)
Ubuntu 16.04 (PowerShell Core 6.0.2)