Powershell: We have $PSEdition, so shall "$IsWindows , $IsLinux , $IsOSX , and $IsCore" be kept in PowerShell Core permanently?

Created on 5 Jul 2016  路  12Comments  路  Source: PowerShell/PowerShell

The variables $IsWindows , $IsLinux , $IsOSX , and $IsCore are now an integral part of PowerShell Core. $PSEdition serves the same purpose in PS Core, so shall the "$is" variables be kept permanently in PowerShell Core?

We should nail down this as early as possible, because existing tests are using the "$is" variables a lot, and new tests would follow the same pattern. It will be more work to clean them up if we decide to remove "$is" variables later.

PS C:> $PSEdition
Core
PS C:>

Committee-Reviewed Issue-Question Resolution-Answered WG-Language

Most helpful comment

The variables are concise, I like that.

Mapping to an api isn't important, especially since the variables should be compile time constants, so for example we can do simple constant propagation while generating code.

I'd vote for going public with the $Is* variables and letting the community convince us it was a bad choice.

All 12 comments

For simplicity, I would say yes. They map directly to the .NET Core APIs.

/cc @JamesWTruher

@lzybkr @vors @HemantMahawar @SandeepSutari @mirichmo Can you guys please comment?

The variables are concise, I like that.

Mapping to an api isn't important, especially since the variables should be compile time constants, so for example we can do simple constant propagation while generating code.

I'd vote for going public with the $Is* variables and letting the community convince us it was a bad choice.

I get & like the $IsWindows , $IsLinux , $IsOSX variables as they imply the OS flavor. But $IsCore doesn't seems to fit the bill ... if it is supposed to be about PowerShell on core CLR, then we should use $PSVersion.PSEdition. ... fyi @joeyaiello @BrucePay @KrishnaV-MSFT

I remember having this discussed, but couldn't find any conclusion posted by the @PowerShell/powershell-committee

@PowerShell/powershell-committee the discussion occurred and decision is here: https://github.com/powershell/powershell/issues/1635#issuecomment-275279483

I still need to write more RFCs....fun....

Since it doesn't appear that the RFC is going to make it for 6.0.0, I'd like to revisit one aspect of this which is renaming $IsOSX to $IsMacOS for consistency (which may also mean renaming our Mac release filename).

Yeah, we should probably move to macOS. We can leave the old one there as an alias too, right? Just make them resolve to the same thing? As for casing, I'm pretty hardcore about 'macOS', but capital M seems the right thing to do here.

Created a separate issue for $IsOSX->$IsmacOS
https://github.com/PowerShell/PowerShell/issues/4700

we don't have a backward compatibility problem _yet_ as this variable doesn't exist in 5x and we haven't released yet. I would rather not carry around state variables where we don't need to and while removing $IsOSX now may be a large PR because of the test changes, better now than after we release.

No longer an issue. What exists will exist forever at this point for these automatic variables.

Was this page helpful?
0 / 5 - 0 ratings