-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Related issue: #4645
run.ps1
Start-Transcript -Path (Join-Path $PSScriptRoot 'transcriptdata.txt')
$InformationPreference = 'SilentlyContinue'
Write-Information 'SilentlyContinue'
$InformationPreference = 'Continue'
Write-Information 'LoudlyContinue'
Stop-TranscriptSteps to reproduce
.\run.ps1Expected behavior
transcriptdata.txt should contains only LoudlyContinue
Actual behavior
transcriptdata.txt contains only SilentlyContinue
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0-preview.1
PSEdition Core
GitCommitId v6.1.0-preview.1
OS Microsoft Windows 10.0.16299
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Investigation
The problem is in if/else statement which starts here:
PowerShell/src/System.Management.Automation/engine/MshCommandRuntime.cs
Lines 757 to 758 in 948532a
| if ((record.Tags.Contains("PSHOST") && (!record.Tags.Contains("FORWARDED"))) | |
| || (preference == ActionPreference.Continue)) |
and has a continuation here:
PowerShell/src/System.Management.Automation/engine/MshCommandRuntime.cs
Lines 824 to 828 in 948532a
| else | |
| { | |
| // Only transcribe informational messages here. Transcription of PSHost-targeted messages is done in the InternalUI.Write* methods. | |
| CBhost.InternalUI.TranscribeResult(StringUtil.Format(InternalHostUserInterfaceStrings.InformationFormatString, record.ToString())); | |
| } |
Transcription of Write-Host commands are handled in InternalUI.Write* methods as the comment suggests. These commands are distinguished by "PSHOST" tag.
Transcription of Write-Information commands is supposed to take place in the else statement but code in this statement is being executed only if
(!record.Tags.Contains("PSHOST") || record.Tags.Contains("FORWARDED"))
&&
preference != ActionPreference.Continue)This condition is invalid. Correct condition is:
!record.Tags.Contains("PSHOST")
&&
preference == ActionPreference.Continue)PR pending...
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime