function Write-Red ($text) {
$color = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = 'Red'
$text
$host.UI.RawUI.ForegroundColor = $color
}
Write-Red 'must be red, it is not in PSF 5.2.3'
Write-Red 'must be red, it is'
It is a generic PS script, not specific for Far.
We can call it by powershell.exe
powershell.exe .\Write-Red.ps1
and it writes two red lines.
To make colored output, the script uses ForegroundColor instead of Write-Host -ForegroundColor .... This technique allows redirection of output, i.e. we can
powershell.exe .\Write-Red.ps1 > log.txt
and log.txt contains our two lines. This is not possible with Write-Host.
This technique of colored output is commonly used in PS, e.g. by
PowerShellFar 5.2.3 Script Write-Red.ps1
It is a generic PS script, not specific for Far. We can call it by powershell.exe
and it writes two red lines.
To make colored output, the script uses
ForegroundColor
instead ofWrite-Host -ForegroundColor ...
. This technique allows redirection of output, i.e. we canand log.txt contains our two lines. This is not possible with
Write-Host
.This technique of colored output is commonly used in PS, e.g. by
Write-Build
WriteColoredOutput
The problem
If we invoke the above script in PSF (or use the mentioned or similar tools in PSF):
then the first line is not colored, as we expect.
The problem is caused by a known change in Far, to be discussed with its author.