Write out OSC indicator only if the stdout is not redirected (#17419)

This commit is contained in:
Dongbo Wang
2022-05-25 14:29:47 -07:00
committed by GitHub
parent 80a207160b
commit 0882737efb
2 changed files with 12 additions and 3 deletions
@@ -237,6 +237,14 @@ Describe 'Tests for $PSStyle automatic variable' {
$PSStyle.Progress.MaxWidth = $maxWidth
}
}
It 'Do not use OSC indicator when the stdout is redirected' {
$pwsh = Join-Path $PSHOME 'pwsh'
## In the case that the stdout is redirected, pwsh should not write the OSC indicator Ansi sequence.
$result = & $pwsh -noprofile -Command { $PSStyle.Progress.UseOSCIndicator = $true; 'hello'} | Format-List
$result | Out-String -Stream | Should -BeExactly 'hello'
}
}
Describe 'Handle strings with escape sequences in formatting' {