You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[System.Console]::ReadKey() returns escape sequence characters when pressing arrow keys in PowerShell on Linux #75305
This is with PowerShell 7.3.0-preview.7, which runs on top of .NET 7-preview.7.
Running [System.Console]::ReadKey() in PowerShell, and then press UpArrow, it returns the escape sequences character by character -- Escape and then A.
It's the same to other arrow keys: DownArrow, LeftArrow, RightArrow
However, when using Console.ReadKey in an EXE built against .NET 7-preview.7, it returns UpArrow (and other arraow keys) as expected. Any ideas about what may cause this difference?
PowerShell doesn't set TERM env variable, it just derives that env variable:
PS:6> $env:TERM
xterm-256color
The PSReadLine module running in PowerShell depends on Console.ReadKey and it works as expected, however, running [Console]::ReadKey directly in PowerShell console doesn't. This is really puzzling and any help is much appreciated.
This is fixed with the .NET 7-RC1 release ❤️ Thanks @adamsitnik!
But I'm still curious about why it only doesn't work when running in PowerShell directly for the previous .NET versions ... what a mystery 😵💫
Activity
daxian-dbw commentedon Sep 8, 2022
Is this also addressed by f1de614?
adamsitnik commentedon Sep 9, 2022
Is there any chance PowerShell could set
TERMenv variable?I am not 100% sure as I don't know what caused the difference in first place. Could you please test it with RC1?
daxian-dbw commentedon Sep 9, 2022
PowerShell doesn't set
TERMenv variable, it just derives that env variable:The PSReadLine module running in PowerShell depends on
Console.ReadKeyand it works as expected, however, running[Console]::ReadKeydirectly in PowerShell console doesn't. This is really puzzling and any help is much appreciated.adamsitnik commentedon Sep 15, 2022
@daxian-dbw RC1 was shipped yesterday, could you please check if it works as expected now?
daxian-dbw commentedon Sep 15, 2022
Thanks @adamsitnik, we are preparing a release targeting RC1. Will verify this soon.
daxian-dbw commentedon Sep 15, 2022
This is fixed with the .NET 7-RC1 release ❤️ Thanks @adamsitnik!
But I'm still curious about why it only doesn't work when running in PowerShell directly for the previous .NET versions ... what a mystery 😵💫
adamsitnik commentedon Sep 16, 2022
Based on #75289 (comment) it looks that I'll have to solve this mystery anyway ;)
adamsitnik commentedon Sep 16, 2022
@daxian-dbw thanks for testing it and letting me know!