Powershell: broken terminal using powershell over ssh from windows

Created on 22 Jun 2017  路  11Comments  路  Source: PowerShell/PowerShell

It appears powershell over SSH going to a Windows console is broken strangely. If you use powershell on Windows to ssh and then powershell, you get the last line repeated everytime you press a character. If you use cmd, it basically keeps writing a single line in place rather than ever moving.

Any other linux tool, nano, vim, etc over SSH work fine. So not sure what powershell is doing in particular that the windows powershell terminal cannot handle while handling more complex terminal abusing applications.

Steps to reproduce

Setup for example the "OpenSSH for Windows" or a msys2 ssh implementation (it doesn't matter which one).

Launch powershell on Windows. Execute the ssh client to a debian 8 machine which has powershell installed via the deb packages.

Execute powershell.

Try typing.

It ends up broken like this:

PS /home/mroszko> PS /home/mroszko> $
PS /home/mroszko> $P
PS /home/mroszko> $PS
PS /home/mroszko> $PSV
PS /home/mroszko> $PSVE
PS /home/mroszko> $PSVER
PS /home/mroszko> $PSVERS
PS /home/mroszko> $PSVERSI
PS /home/mroszko> $PSVERSIO
PS /home/mroszko> $PSVERSION
PS /home/mroszko> $PSVERSIONT
PS /home/mroszko> $PSVERSIONTA
PS /home/mroszko> $PSVERSIONTAB
PS /home/mroszko> $PSVERSIONTABL
PS /home/mroszko> $PSVERSIONTABLE

When I was simply trying to type $PSVERSIONTABLE, it automatically kept regenerating the line.
Other strange artifacts can occur instead too, cursor not moving, lines jumping, buffer bleeding.

Environment data

Name Value ---- ----- PSVersion 6.0.0-beta PSEdition Core BuildVersion 3.0.0.0 CLRVersion GitCommitId v6.0.0-beta.2 OS Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0

What I've tried:

Cmder/Conemu which wrap Cmd.exe and PowerShell.exe

Powershell.exe standalone with OpenSSH for Windows and msys2 ssh separately
Cmd.exe standalone with OpenSSH for Windows and msys2 ssh separately

Issue-Discussion Resolution-Fixed WG-Interactive-PSReadLine

Most helpful comment

I have some work in progress in this area, but this change would probably help a lot - note that I haven't even compiled it and don't have a Linux VM handy, but if someone wants to test it out, feel free.

All 11 comments

ConEmu-2017-06-22-p23400.txt

Uploaded the debug output from Conemu which shows the received characters and escape sequences. (You may have to scroll right to see the entire file if you don't have word wrap)

The last log was from powershell as the windows host.

This log is way way more interesting as its cmd.exe as the windows host and shows all the escape sequences.
ConEmu-2017-06-22-p30324.txt

It starts off with me doing a non-powershell cd, ls and touch. Then I execute powershell and the fun begins.

In powershell there were only two commands executed:

ls -al
exit

@marekr Thanks for your report!

show extreme escape sequence spam

The PowerShell Core supports colors and therefore rewrites the output line after typing every char.

The PowerShell Core supports colors and therefore rewrites the output line after typing every char.

The very vast majority of the escape sequences appear duplicate "Set Attribute mode" to color as red per line. I'm talking a hundred ESC[39;49 m characters if look.

PS /home/mroszko/test>

Can't the engine be smarter and not call "Set Attribute Mode" per character? I've tested Nano with syntax highlighting, bash with highlighting, etc, they don't spam the control codes like powershell.

https://youtu.be/4DwEpG0WbEg

Screen cap of the the behavior

Another thing to note, the general performance seems to be very bad just hitting new/line enter.

@lzybkr Could you please comment?

Investing in PSReadline is something I plan to have my team members do for 6.1.0.

I have some work in progress in this area, but this change would probably help a lot - note that I haven't even compiled it and don't have a Linux VM handy, but if someone wants to test it out, feel free.

@lzybkr I tested your change (With a tweak, it won't compile without parenthesis around the -1 defaults) and it does improve the responsiveness of the console alot. The ladder step lines no longer occur either (not that it should have fixed that).

The main benefit its easier to stare at the log file now to further debug. Attached sample.

ConEmu-2017-06-26-p18872.txt

@marekr - thanks for testing - we'll get this in and hopefully I'll get to the much improved renderer at some point.

@lzybkr no problem

Just to add, there are still some issues where the line isn't incrementing properly upon hitting enter (sparsely) or upon calling powershell from bash when the bash prompt is halfway down the screen, powershell fails to use the upper screen real estate.

@marekr - thanks for testing! If you see other problems - feel free open new Issues - your feedback is very useful!

Was this page helpful?
0 / 5 - 0 ratings