From 74950663cf4182f257563b1efa2cdf8eb6250b47 Mon Sep 17 00:00:00 2001 From: Chris Mumford Date: Mon, 8 Nov 2021 18:47:35 -0800 Subject: [PATCH] Define $IsWindows if not defined. The `$IsWindows` PowerShell variable was added in PowerShell Core 6 and PowerShell 7, and is not present in earlier PowerShell versions. Set to true if undefined. This fixes https://github.com/espressif/esp-idf/issues/7820. The first version to run on non-Windows platforms was PowerShell Core 6.0[^1] which means that IsWindows is guaranteed to be defined on all non-Windows systems. So, if undefined this indicates a Windows platform. [^1]: https://docs.microsoft.com/en-us/powershell/scripting/install/powershell-support-lifecycle?view=powershell-7.2#release-history Closes https://github.com/espressif/esp-idf/pull/7858 Closes https://github.com/espressif/esp-idf/issues/7820 --- export.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/export.ps1 b/export.ps1 index 4ecf066eb5..7efc639ca5 100644 --- a/export.ps1 +++ b/export.ps1 @@ -23,6 +23,11 @@ foreach ($line in $envars_raw) { $envars_array += (, ($var_name, $var_val)) } +if ($IsWindows -eq $null) { + # $IsWindows was added in PowerShell Core 6 and PowerShell 7. + $IsWindows = $true +} + foreach ($pair in $envars_array) { # setting the values $var_name = $pair[0].Trim() # trim spaces on the ends of the name