Skip to content

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

Merged
merged 2 commits into from
Mar 22, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/Install-VSCode.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<#PSScriptInfo

.VERSION 1.1
.VERSION 1.2

.GUID 539e5585-7a02-4dd6-b9a6-5dd288d0a5d0

Expand All @@ -25,6 +25,8 @@
.EXTERNALSCRIPTDEPENDENCIES

.RELEASENOTES
20/03/2018 - fix OS detection to prevent error
--
28/12/2017 - added functionality to support 64-bit versions of VSCode
& support for installation of VSCode Insiders Edition.
--
Expand Down Expand Up @@ -129,7 +131,7 @@ param(
[switch]$LaunchWhenDone
)

if (!($IsLinux -or $IsOSX)) {
if ($env:windir -ne $null) {
Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Member

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.

switch ($Architecture) {
"64-bit" {
if ((Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture -eq "64-bit") {
Expand Down