Title: The -f operator doesn't recognize a [psobject]-wrapped array · Issue #14355 · PowerShell/PowerShell · GitHub
Open Graph Title: The -f operator doesn't recognize a [psobject]-wrapped array · Issue #14355 · PowerShell/PowerShell
X Title: The -f operator doesn't recognize a [psobject]-wrapped array · Issue #14355 · PowerShell/PowerShell
Description: Note: This is ultimately another manifestation of #5579. -f, when passed an array that is invisibly [psobject]-wrapped, fails to recognize the array as such. This can happen with arrays returned as a whole from cmdlets, such as with Writ...
Open Graph Description: Note: This is ultimately another manifestation of #5579. -f, when passed an array that is invisibly [psobject]-wrapped, fails to recognize the array as such. This can happen with arrays returned as...
X Description: Note: This is ultimately another manifestation of #5579. -f, when passed an array that is invisibly [psobject]-wrapped, fails to recognize the array as such. This can happen with arrays returned as...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/14355
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"The -f operator doesn't recognize a [psobject]-wrapped array","articleBody":"Note: This is ultimately another manifestation of #5579.\r\n\r\n`-f`, when passed an array that is invisibly `[psobject]`-wrapped, fails to recognize the array as such.\r\n\r\nThis can happen with arrays returned _as a whole_ from cmdlets, such as with `Write-Output -NoEnumerate` and `Get-Content -ReadCount`.\r\n\r\nSimplest, but contrived repro: `'{0} {1}' -f ([psobject] (1, 2))`\r\n\r\nNote:\r\n* When using an untyped function/script _parameter_, `[psobject]` wrapping does _not_ occur with arrays; it does, however, occur with scalar barewords that can be parsed _as numbers_, and then causes a similar problem: #17199\r\n\r\n\r\n## Steps to reproduce\r\n\r\n```powershell\r\n# Create two 2-element arrays: one with an expression, another via a cmdlet.\r\n$arr1 = 1, 2\r\n$arr2 = Write-Output -NoEnumerate 1, 2\r\n\r\n'{0} {1}' -f $arr1 | Should -Be '1 2'\r\n'{0} {1}' -f $arr2 | Should -Be '1 2'\r\n```\r\n\r\n## Expected behavior\r\n\r\nBoth tests should succeed.\r\n\r\n## Actual behavior\r\n\r\nThe 2nd test fails, because `$arr2` is (invisibly) `[psobject]`-wrapped.\r\n\r\n```none\r\nInvalidOperation: Error formatting a string: Index (zero based) must be greater than or equal to zero and less than the size of the argument list..\r\n```\r\n\r\n## Environment data\r\n\r\n```none\r\nPowerShell Core 7.2.0-preview.1\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2020-12-08T21:35:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/14355/PowerShell/issues/14355"}
| 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:44a2776d-b766-d4a4-d737-2f413ae632d4 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D742:1E1ACC:D505A3:11E50C9:6A5B5EBC |
| html-safe-nonce | cf572a7c2f976437e30a7733d17fbd98ce693b7b9d23adae47e45e05b35b2ce0 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzQyOjFFMUFDQzpENTA1QTM6MTFFNTBDOTo2QTVCNUVCQyIsInZpc2l0b3JfaWQiOiIyNjAwMjI2MTk4Mzg0MjM4MjY4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 70750c8b3a00bbda8267fe58b515d78bf39320a78180685014ea6d5ecc342398 |
| hovercard-subject-tag | issue:759799621 |
| 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/14355/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3523c2d9f59ba9497a15ec8316f7a3b0743d466197b0d5ba5b6e0ba0382e093b/PowerShell/PowerShell/issues/14355 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3523c2d9f59ba9497a15ec8316f7a3b0743d466197b0d5ba5b6e0ba0382e093b/PowerShell/PowerShell/issues/14355 |
| og:image:alt | Note: This is ultimately another manifestation of #5579. -f, when passed an array that is invisibly [psobject]-wrapped, fails to recognize the array as such. This can happen with arrays returned as... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5290d7e14309ad1e76106a9c4237bd1041517e83ea182c8ab756752cb0c6940b |
| 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 | 9c975978430e9ad293956f2bbdaf153b1bd84a99 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width