René's URL Explorer Experiment


Title: Some scripts / files with wildcard metacharacter [ in the file name or path cannot be invoked or redirected to · Issue #4726 · PowerShell/PowerShell · GitHub

Open Graph Title: Some scripts / files with wildcard metacharacter [ in the file name or path cannot be invoked or redirected to · Issue #4726 · PowerShell/PowerShell

X Title: Some scripts / files with wildcard metacharacter [ in the file name or path cannot be invoked or redirected to · Issue #4726 · PowerShell/PowerShell

Description: Edited for the current status as of PowerShell Core 7.3.0-preview.4 Note: Originally, this issue was also about the inability to execute files whose literal names happen to be syntactically invalid wildcard patterns. This execution aspec...

Open Graph Description: Edited for the current status as of PowerShell Core 7.3.0-preview.4 Note: Originally, this issue was also about the inability to execute files whose literal names happen to be syntactically invalid...

X Description: Edited for the current status as of PowerShell Core 7.3.0-preview.4 Note: Originally, this issue was also about the inability to execute files whose literal names happen to be syntactically invalid...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/4726

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Some scripts / files with wildcard metacharacter [ in the file name or path cannot be invoked or redirected to","articleBody":"\u003csup\u003eEdited for the current status as of PowerShell Core 7.3.0-preview.4\u003c/sup\u003e\r\n\r\nNote: \r\n\r\n* Originally, this issue was also about the inability to _execute_ files whose literal names happen to be syntactically invalid wildcard patterns. \r\n\r\n* This execution aspect was _partially_ fixed in #9202 (but wasn't back-ported to the currently stable version, v6.2.3)\r\n  * Invocation by wildcard pattern still works as a fallback, but paths with `[` and `]` that exist _literally_ now take precedence.\r\n  * Therefore, **if no literal match is present, you may still end up invoking an unrelated file by accident**, which is problematic (e.g., if `a.ps1` is present in the current dir. and `.\\[ab].ps1` is invoked, with no file _literally_ named `[ab].ps1` present, `.\\a.ps1` is executed instead.)\r\n\r\nSeemingly, all external-executable invocation methods ( `.`, `\u0026`, `Start-Process`, `powershell -File`) as well as redirections `\u003e` / `\u003e\u003e` mistakenly interpret script / file paths as _wildcard patterns_, and if  a path that contains `[` happens not contain a syntactically valid range expression, invocation and redirection _break_ (in _Windows PowerShell_, no longer in PowerShell Core, except with `Start-Process`) or can end up accidentally targeting an unrelated executable.\r\n\r\n* In other words: The problem _sometimes_ occurs, unless each instance of `[` happens to be part of a _valid_ range expression; e.g., `a[b]` (valid) vs. `a[b` (invalid); curiously, however, the equally invalid `b[b` does not.\r\n\r\n* But even with a syntactically valid range expression - and some invalid ones - the behavior is unexpected:\r\n\r\n  * `'foo' \u003e 'file[1].txt'` attempts wildcard matching and complains, `Cannot perform operation because the wildcard path file[1].txt did not resolve to a file.`\r\n    * Attempting _escaping_ then inappropriately retains the escape characters - see #9475\r\n\r\n* Attempting to invoke (open) such a file fails quietly, even with escaping (run `New-Item file[1].txt` first):\r\n  * `./file[1].txt` ... quiet no-op\r\n  * ``./file`[1`].txt`` ... quiet no-op\r\n  * If you created a `.ps1` file named, say, `file[1].ps1` (`'\"hi\"' | Set-Content -LiteralPath file[1].ps1`):\r\n    * Invocation with an explicit path unexpectedly only works if `.ps1` is also specified.\r\n    * Invocation via $env:PATH doesn't work at all - neither with or without `.ps1`\r\n\r\n**Fundamentally, external-executable / redirection output paths should be treated as _literals_ in these situations.**\r\nSee [this comment](https://github.com/PowerShell/PowerShell/issues/17106#issuecomment-1088755835) for a discussion and an overview of related issues.\r\n\r\nOriginal tests below.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\nRun the following Pester tests.\r\n\r\n```powershell\r\nDescribe \"Redirection with and invocation of literal file paths that are invalid as wildcard patterns\" {\r\n\r\n  BeforeAll {\r\n    Push-Location testdrive:\\\r\n    $f1 = './t[1.ps1'\r\n    $f2 = './t[1.txt'\r\n    New-Item -Type File $f1 -Value \"'hi'\"\r\n  }\r\n\r\n # Passes now, due to fix in #9202\r\n  It \"Script file can be dot-sourced.\" {\r\n    . $f1 | Should -Be 'hi'\r\n  }\r\n\r\n # Passes now, due to fix in #9202\r\n  It \"Script file can be called.\" {\r\n    \u0026 $f1 | Should -Be 'hi'\r\n  }\r\n\r\n # Passes now, due to fix in #9202\r\n  It \"Script file can be called via CLI with -File\" {\r\n    pwsh -noprofile -file $f1 | Should -Be 'hi'\r\n  }\r\n\r\n  It \"Redirection works with new file (\u003e)\" {\r\n    \u0026 { 'hi' \u003e $f2; Get-Content -LiteralPath $f2 } | Should -Be 'hi'\r\n  }\r\n\r\n  It \"Redirection works with existing file (\u003e)\" {\r\n    New-Item -Force -Type File $f2\r\n    \u0026 { 'hi' \u003e $f2; Get-Content -LiteralPath $f2 } | Should -Be 'hi'\r\n  }\r\n\r\n  It \"File path is passed correctly to external programs\" {\r\n    if ($IsWindows) {\r\n      cmd /c type ($f1 -replace '/', '\\') | Should -Be \"'hi'\"\r\n    } else {\r\n      /bin/cat $f1 | Should -Be \"'hi'\"\r\n    }\r\n  }\r\n\r\n  AfterAll {\r\n    Pop-Location\r\n  }\r\n}\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nAll tests should pass.\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe `\u003e` tests fail on all platforms.\r\n\r\nIn v6.2.3, the invocation tests fail too.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core 7.0.0-preview.5\r\n```\r\n\r\nOriginally reported for PowerShell Core v6.0.0-beta.7.\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-08-31T16:34:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":27},"url":"https://github.com/4726/PowerShell/issues/4726"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:cae5521d-9158-165f-f3e5-088303427de6
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8260:223D7:9A49BE:D18F0B:6A581AE7
html-safe-nonce5d10f4eea422b7d3d63c91a3ddc28e14eb6b1405474ec8debf836f7cd3f5ff13
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjYwOjIyM0Q3OjlBNDlCRTpEMThGMEI6NkE1ODFBRTciLCJ2aXNpdG9yX2lkIjoiMjM4NjQ5ODE3MTc4NDY2NTgzMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac17dc9be3a574a4c45897a0a4127167e0492908c6cec593a000a365d8d71b2a39
hovercard-subject-tagissue:254396076
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/4726/issue_layout
twitter:imagehttps://opengraph.githubassets.com/66176b0a86c1639743d7c0f9efa443ea7b15cdb4ca70c82f6b236c6efdbe1f38/PowerShell/PowerShell/issues/4726
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/66176b0a86c1639743d7c0f9efa443ea7b15cdb4ca70c82f6b236c6efdbe1f38/PowerShell/PowerShell/issues/4726
og:image:altEdited for the current status as of PowerShell Core 7.3.0-preview.4 Note: Originally, this issue was also about the inability to execute files whose literal names happen to be syntactically invalid...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
None49c8c15fabcbf356d607a90ca115c13b273e42ff8b74155de050fd229a9b0121
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3fb1f684e7a833eb1b2d01d39875a2b52cb4fe9b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/4726#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F4726
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F4726
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/4726
Reloadhttps://github.com/PowerShell/PowerShell/issues/4726
Reloadhttps://github.com/PowerShell/PowerShell/issues/4726
Please reload this pagehttps://github.com/PowerShell/PowerShell/issues/4726
PowerShell https://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Notifications https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Fork 8.4k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Star 54.4k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Code https://github.com/PowerShell/PowerShell
Issues 1.2k https://github.com/PowerShell/PowerShell/issues
Pull requests 291 https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality 3 https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Code https://github.com/PowerShell/PowerShell
Issues https://github.com/PowerShell/PowerShell/issues
Pull requests https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Some scripts / files with wildcard metacharacter [ in the file name or path cannot be invoked or redirected tohttps://github.com/PowerShell/PowerShell/issues/4726#top
In-PRIndicates that a PR is out for the issuehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22In-PR%22
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Enginecore PowerShell engine, interpreter, and runtimehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine%22
https://github.com/mklement0
mklement0https://github.com/mklement0
on Aug 31, 2017https://github.com/PowerShell/PowerShell/issues/4726#issue-254396076
Make command searcher not use wildcard search for execution #9202https://github.com/PowerShell/PowerShell/pull/9202
Passing an escaped wildcard expression to -Path in file-creating cmdlets causes the escaped representation to be used as the literal filename #9475https://github.com/PowerShell/PowerShell/issues/9475
this commenthttps://github.com/PowerShell/PowerShell/issues/17106#issuecomment-1088755835
In-PRIndicates that a PR is out for the issuehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22In-PR%22
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Enginecore PowerShell engine, interpreter, and runtimehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.