Powershell: Piping to less on Windows results in invisible text after executing a Git command

Created on 7 Jul 2019  路  7Comments  路  Source: PowerShell/PowerShell

Steps to reproduce

First get a copy of less for Windows and put it in your path or use Chocolatey - choco install less.

PS> "All work and no play makes Jack a dull boy!`n" * 180 | less
PS> cd ~\github\powershell
PS> git log
PS> "All work and no play makes Jack a dull boy!`n" * 180 | less

Expected behavior

The second time you pipe to less you should still be able to see the text

Actual behavior

The screen is blank or the text is very faintly visible depending on your color scheme.

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.1
PSEdition                      Core
GitCommitId                    6.2.1
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0鈥
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Issue-Question Resolution-External

Most helpful comment

This is a bug in less, see https://github.com/gwsw/less/pull/26.
I have a patched binary (with one other unmerged fix) here.

All 7 comments

@rkeithhill Do you see the issue with latest PowerShell 7.0 and PSReadline 2.0?

Unfortunately yes. I see it on 7.0 GA and 7.1 preview.2 with PSRL 2.1 Beta1. I'm using less version 551 (installed via Chocolatey). Note that this doesn't happen when you first start the console. You have to run some commands first and then after a while, the help text piped to less becomes very dim. I'm not sure what color index it is using. I'll see if I can find out.

OK, when less misbehaves it starts using foreground black ("\e[30m") for text.

Do you expect an fix in the repo or we can close the issue as external?

I'm a bit puzzled why running Clear-Host fixes the issues - for a while.

Hmm, looks like the ClearHostFunctionText resets the foreground color:

    @{Character = ' '; ForegroundColor = $rawui.ForegroundColor; BackgroundColor = $rawui.BackgroundColor})

I suppose that is why running cls temporarily fixes the issue.

This is a bug in less, see https://github.com/gwsw/less/pull/26.
I have a patched binary (with one other unmerged fix) here.

Was this page helpful?
0 / 5 - 0 ratings