diff --git a/PowerShellEditorServices.build.ps1 b/PowerShellEditorServices.build.ps1 index 76687aa65..6bde9dd8a 100644 --- a/PowerShellEditorServices.build.ps1 +++ b/PowerShellEditorServices.build.ps1 @@ -33,7 +33,7 @@ $script:IsNix = $IsLinux -or $IsMacOS # For Apple M1, pwsh might be getting emulated, in which case we need to check # for the proc_translated flag, otherwise we can check the architecture. $script:IsAppleM1 = $IsMacOS -and ((sysctl -n sysctl.proc_translated) -eq 1 -or (uname -m) -eq "arm64") -$script:IsArm64 = $IsWindows -and @("ARM64", "AMD64") -contains $env:PROCESSOR_ARCHITECTURE +$script:IsArm64 = -not $script:IsNix -and @("ARM64", "AMD64") -contains $env:PROCESSOR_ARCHITECTURE $script:BuildInfoPath = [System.IO.Path]::Combine($PSScriptRoot, "src", "PowerShellEditorServices.Hosting", "BuildInfo.cs") $script:PsesCommonProps = [xml](Get-Content -Raw "$PSScriptRoot/PowerShellEditorServices.Common.props") diff --git a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs index 8dcce509b..69b9f0d72 100644 --- a/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs +++ b/src/PowerShellEditorServices/Services/PowerShell/Host/PsesInternalHost.cs @@ -7,7 +7,6 @@ using System.IO; using System.Management.Automation.Host; using System.Reflection; -using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -981,8 +980,6 @@ private static PowerShell CreatePowerShellForRunspace(Runspace runspace) readLineProvider.OverrideReadLine(readLine); System.Console.CancelKeyPress += OnCancelKeyPress; - System.Console.InputEncoding = Encoding.UTF8; - System.Console.OutputEncoding = Encoding.UTF8; } if (VersionUtils.IsWindows) diff --git a/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs b/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs index b3cd602b6..179da5f8c 100644 --- a/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs +++ b/test/PowerShellEditorServices.Test/Session/PsesInternalHostTests.cs @@ -172,5 +172,15 @@ public async Task CanLoadPSReadLine() out IReadLine readLine), CancellationToken.None).ConfigureAwait(true)); } + + // This test asserts that we do not mess up the console encoding, which leads to native + // commands receiving piped input failing. + [Fact] + public async Task ExecutesNativeCommandsCorrectly() + { + await psesHost.ExecutePSCommandAsync( + new PSCommand().AddScript("\"protocol=https`nhost=myhost.com`nusername=john`npassword=doe`n`n\" | git.exe credential approve; if ($LastExitCode) { throw }"), + CancellationToken.None).ConfigureAwait(true); + } } }