X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1693,6 +1693,9 @@ private void CalculateIORedirection(bool isWindowsApplication, out bool redirect
{
if (s_supportScreenScrape == null)
{
#if UNIX
s_supportScreenScrape = false;
#else
try
{
_startPosition = this.Command.Context.EngineHostInterface.UI.RawUI.CursorPosition;
Expand All @@ -1704,6 +1707,7 @@ private void CalculateIORedirection(bool isWindowsApplication, out bool redirect
{
s_supportScreenScrape = false;
}
#endif
}

// if screen scraping isn't supported, we enable redirection so that the output is still transcribed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,3 +366,28 @@ Describe "Run native command from a mounted FAT-format VHD" -tags @("Feature", "
$result | Should -BeExactly $expected
}
}

Describe "Native application invocation and getting cursor position" -Tags 'CI' {
It "Invoking a native application should not collect the cursor position" -Skip:($IsWindows) {
$expectCmd = Get-Command expect -Type Application -ErrorAction Ignore
$dateCmd = Get-Command date -Type Application -ErrorAction Ignore
# if date or expect are missing mark the test as pending
# test setup will need to ensure that these programs are present.
$missing = @()
if ($null -eq $expectCmd) {
$missing += "expect"
}
if ($null -eq $dateCmd) {
$missing += "date"
}
if ($missing.count -ne 0) {
$message = "missing command(s) {0}" -f ($missing -join ", ")
Set-ItResult -Pending -Because $message
}

$powershell = Join-Path -Path $PSHOME -ChildPath "pwsh"
$commandString = "spawn $powershell -nopro -c /bin/date; expect eof"
[string]$result = expect -c $commandString
$result.IndexOf("`e[6n") | Should -Be -1 -Because $result.replace("`e","``e").replace("`u{7}","<BELL>")
}
}
X Tutup