From a082a02e6c14285ad839665b3190ab23eae850fc Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 8 Apr 2016 15:04:27 -0700 Subject: [PATCH] Add PowerShell variables corresponding to platform This deprecates the Microsoft.PowerShell.Platform module and ensure that IsLinux/OSX/Windows/Core variables are defined all throughout PowerShell. --- .../engine/InitialSessionState.cs | 26 +++++++++++++++++++ .../engine/SpecialVariables.cs | 14 ++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index e1d807dcaf..f0c84c5b67 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -5101,6 +5101,32 @@ end RemotingErrorIdStrings.PSSessionAppName, ScopedItemOptions.None), // End: Variables which control remoting behavior + + #region Platform + new SessionStateVariableEntry( + SpecialVariables.IsLinux, + Platform.IsLinux, + String.Empty, + ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), + + new SessionStateVariableEntry( + SpecialVariables.IsOSX, + Platform.IsOSX, + String.Empty, + ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), + + new SessionStateVariableEntry( + SpecialVariables.IsWindows, + Platform.IsWindows, + String.Empty, + ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), + + new SessionStateVariableEntry( + SpecialVariables.IsCore, + Platform.IsCore, + String.Empty, + ScopedItemOptions.ReadOnly | ScopedItemOptions.AllScope), + #endregion }; /// diff --git a/src/System.Management.Automation/engine/SpecialVariables.cs b/src/System.Management.Automation/engine/SpecialVariables.cs index 2f6dd0a014..a6a83d8837 100644 --- a/src/System.Management.Automation/engine/SpecialVariables.cs +++ b/src/System.Management.Automation/engine/SpecialVariables.cs @@ -156,6 +156,20 @@ namespace System.Management.Automation internal const string PSModuleAutoLoading = "PSModuleAutoLoadingPreference"; internal static VariablePath PSModuleAutoLoadingPreferenceVarPath = new VariablePath("global:" + PSModuleAutoLoading); + #region Platform Variables + internal const string IsLinux = "IsLinux"; + internal static VariablePath IsLinuxPath = new VariablePath("IsLinux"); + + internal const string IsOSX = "IsOSX"; + internal static VariablePath IsOSXPath = new VariablePath("IsOSX"); + + internal const string IsWindows = "IsWindows"; + internal static VariablePath IsWindowsPath = new VariablePath("IsWindows"); + + internal const string IsCore = "IsCore"; + internal static VariablePath IsCorePath = new VariablePath("IsCore"); + + #endregion #region Preference Variables internal const string DebugPreference = "DebugPreference";