Repository navigation
Closed
Labels
Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
$? of redirection >, >>, 2>, and 2>> is unexpected.
Expected behavior
PS> "hello"
hello
PS> "abc" > $null
PS> $?
True
PS>
PS>
PS> 2 + "a"
InvalidArgument: Cannot convert value "a" to type "System.Int32". Error: "Input string was not in a correct format."
PS> "abc" > $null
PS> $?
TrueActual behavior
PS> "hello"
hello
PS> "abc" > $null
PS> $?
True
PS>
PS>
PS> 2 + "a"
InvalidArgument: Cannot convert value "a" to type "System.Int32". Error: "Input string was not in a correct format."
PS> "abc" > $null
PS> $?
FalseError details
No response
Environment data
Name Value
---- -----
PSVersion 7.1.4
PSEdition Core
GitCommitId 7.1.4
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name Value
---- -----
PSVersion 7.2.0-preview.9
PSEdition Core
GitCommitId 7.2.0-preview.9
OS Microsoft Windows 10.0.19042
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtime

Activity
vexx32 commentedon Sep 1, 2021
I'm seeing the same on the latest preview. I wonder if this is because it's considered a 'pure' expression and thus doesn't set
$?? was it an intentional change in this instance?XValue commentedon Sep 1, 2021
I don't think it's considered a 'pure' expression.
PS> "hello"
hello
PS> "abc" > C:\1.txt
Out-File: Access to the path 'C:\1.txt' is denied.
PS> $?
False
daxian-dbw commentedon Sep 3, 2021
The Engine WG reviewed this issue and agreed this is a bug that should be fixed. Hopefully #16046 will fix it.