-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
Steps to reproduce
Set-Content -Value $null -Path .\zero.txt -NoNewline -Encoding Ascii
(get-item .\zero.txt).Length -eq 0 # returns $true
$content = gc .\zero.txt -Raw -Encoding Ascii
$content -eq $null # returns $true
$null -eq $content # returns $true
$content -match 'anything' # returns nothing, but should return $false
[System.Management.Automation.Internal.AutomationNull]::Value -match 'anything' # ditto
$null -match 'anything' # returns $falseExpected behavior
$true
$true
$true
$false
$false
$falseActual behavior
$true
$true
$true
# returns nothing at all
# returns nothing at all
$falseImpact
This makes it more difficult to write scripts that process content in files, because tests that should fail return nothing instead, so if you were checking for a failure and then jumping to the next iteration of the loop with continue, your continue does not get called and then unpredictable things can happen as a result.
Environment data
Reproduced in PowerShell 5.1 and 6.0.
fMichaleczek
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime