Title: [S.M.A.Internal.AutomationNull]::Value is treated like a collection when used with -match, -notmatch, -like, -notlike · Issue #3866 · PowerShell/PowerShell · GitHub
Open Graph Title: [S.M.A.Internal.AutomationNull]::Value is treated like a collection when used with -match, -notmatch, -like, -notlike · Issue #3866 · PowerShell/PowerShell
X Title: [S.M.A.Internal.AutomationNull]::Value is treated like a collection when used with -match, -notmatch, -like, -notlike · Issue #3866 · PowerShell/PowerShell
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 $conten...
Open Graph 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...
X 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...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3866
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[S.M.A.Internal.AutomationNull]::Value is treated like a collection when used with -match, -notmatch, -like, -notlike","articleBody":"Steps to reproduce\r\n------------------\r\n```PowerShell\r\nSet-Content -Value $null -Path .\\zero.txt -NoNewline -Encoding Ascii\r\n(get-item .\\zero.txt).Length -eq 0 # returns $true\r\n$content = gc .\\zero.txt -Raw -Encoding Ascii\r\n$content -eq $null # returns $true\r\n$null -eq $content # returns $true\r\n$content -match 'anything' # returns nothing, but should return $false\r\n[System.Management.Automation.Internal.AutomationNull]::Value -match 'anything' # ditto\r\n$null -match 'anything' # returns $false\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n```PowerShell\r\n$true\r\n$true\r\n$true\r\n$false\r\n$false\r\n$false\r\n```\r\n\r\nActual behavior\r\n---------------\r\n```PowerShell\r\n$true\r\n$true\r\n$true\r\n# returns nothing at all\r\n# returns nothing at all\r\n$false\r\n```\r\n\r\nImpact\r\n------\r\nThis 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.\r\n\r\nEnvironment data\r\n----------------\r\nReproduced in PowerShell 5.1 and 6.0.","author":{"url":"https://github.com/KirkMunro","@type":"Person","name":"KirkMunro"},"datePublished":"2017-05-25T21:42:59.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":22},"url":"https://github.com/3866/PowerShell/issues/3866"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c61de024-b0cc-0edb-ca9f-7fdd5650237e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CDCE:70EA8:10E4A44:181CF0A:6A5A17A6 |
| html-safe-nonce | 6f347c1fb6c645e872f78235b96845bd48c003c9e4e0bf0067aeaa7350119b2b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRENFOjcwRUE4OjEwRTRBNDQ6MTgxQ0YwQTo2QTVBMTdBNiIsInZpc2l0b3JfaWQiOiIxNTIyNjY5ODEyMDY1MTE0MDIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 879c635fe3f2398e5ae231fe1e728122bf34669d67fe754e76855845dcb743ad |
| hovercard-subject-tag | issue:231468314 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/3866/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a38f03e92f3f1ad92e5e233593c03f627bade10093d25d32413671149e4e4db1/PowerShell/PowerShell/issues/3866 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a38f03e92f3f1ad92e5e233593c03f627bade10093d25d32413671149e4e4db1/PowerShell/PowerShell/issues/3866 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | KirkMunro |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8c2fe7351e4e987cb8f75e2425a0b895d807779bc4c2d3c312be0a54082219f7 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 501ec24a694e4933bb3d70e768b1461c0def57a2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width