René's URL Explorer Experiment


Title: Parsing of compound command-line tokens into arguments is surprising · Issue #6467 · PowerShell/PowerShell · GitHub

Open Graph Title: Parsing of compound command-line tokens into arguments is surprising · Issue #6467 · PowerShell/PowerShell

X Title: Parsing of compound command-line tokens into arguments is surprising · Issue #6467 · PowerShell/PowerShell

Description: The primary purpose of this issue to highlight how the existing behavior may be surprising to newcomers (and even for seasoned users hard to remember and therefore predict in specific situations). Given that the behavior has been around ...

Open Graph Description: The primary purpose of this issue to highlight how the existing behavior may be surprising to newcomers (and even for seasoned users hard to remember and therefore predict in specific situations). ...

X Description: The primary purpose of this issue to highlight how the existing behavior may be surprising to newcomers (and even for seasoned users hard to remember and therefore predict in specific situations). ...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Parsing of compound command-line tokens into arguments is surprising","articleBody":"* The primary purpose of this issue to highlight how the existing behavior may be surprising to newcomers (and even for seasoned users hard to remember and therefore predict in specific situations).\r\n\r\n* Given that the behavior has been around since the beginning, changing it is probably not an option, but _documenting_ how the behavior may be surprising is worth doing; while _some_ aspects of the behavior can be inferred from [`about_Parsing`](https://github.com/PowerShell/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Parsing.md), the overall implications aren't clear.\r\n  * @SteveL-MSFT: This issue subsumes #3217, which therefore no longer needs the `Documentation Needed` label.\r\n\r\n* While this may ultimately become a [documentation-repo issue](https://github.com/PowerShell/PowerShell-Docs/issues), I would first like to solicit some feedback as to what code changes, if any, should be considered, after all (there are edge cases), and as to whether my summary is accurate.\r\n\r\n* While there may be good _technical_ reasons for these behaviors, the problem is that they may be unexpected, especially given the deviation from how `cmd.exe` and `bash` handle these scenarios.\r\n\r\n* All surprising behaviors can be avoided with proper _quoting_ - which is also worth pointing out in the docs -  but the need to quote negates one of the convenient aspects of argument syntax. If at the end of the day you cannot remember whether a particular token _requires_ quoting, your choices are to resort to trial and error, or to quote _everything_, which is cumbersome.\r\n\r\nNote: By **_compound command-line token_** I mean a **logically single token composed of the _following syntax constructs_ by _direct concatenation_**:\r\n \r\n* barewords (unquoted strings without special meaning; e.g., `foo`)\r\n* quoted strings (e.g.; `'bar'`, `\"baz\"`)\r\n* variable references (`$foo`) and subexpressions (`$(...)`)\r\n\r\nExamples:\r\n\r\n* `bar${foo}` and `${foo}bar` and `$($foo)bar`\r\n* `foo\"bar\"` and `\"bar\"foo`\r\n\r\n**The surprising aspects are**:\r\n\r\n### Asymmetry: Whether a quoted string or subexpression comes _first_ matters:\r\n\r\nPlacing the quoted string or subexpression _first_ results in *2* arguments:\r\n\r\n```powershell\r\nPS> Write-Output 'hi'there\r\nhi\r\nthere\r\n\r\n> Write-Output $($env:HOME)/Documents\r\n/Users/jdoe\r\n/Documents\r\n```\r\n\r\nOtherwise, a _single_ argument is passed, as expected:\r\n\r\n```powershell\r\nPS> Write-Output hi'there'\r\nhithere\r\n\r\nPS> Write-Output Documents:$($env:HOME)  # Note: just $env:HOME without $() is not affected.\r\nDocuments:/Users/jdoe\r\n```\r\n\r\n###  `.` following a leading quoted string is interpreted as [string] property access\r\n\r\n```powershell\r\nPS> Write-Output 'hi'.there\r\n   # NO output, because an attempt is made to access property .there on the string instance\r\n```\r\n\r\n###  `.` as the initial char. followed by a quoted string results in *2* arguments\r\n\r\n```powershell\r\nPS> Write-Output .'hi'\r\n.\r\nhi\r\n```\r\n\r\n###  `-` as the initial char. in something that turns out _not_ to be a parameter name  results in *2* arguments with the presence of `:` or `.` \r\n\r\nSee also: #6292 and #6360.\r\n\r\n```powershell\r\nPS> Write-Output -foo:bar\r\n-foo:\r\nbar\r\n\r\nPS> Write-Output -ip=10.0.0.1\r\n-ip=10\r\n.0.0.1\r\n```\r\n###  `-` as the initial char. causes embedded variable references not to be expanded\r\n\r\nSee also: #4624.\r\n\r\n```powershell\r\nPS> Write-Output a$HOME\r\na/home/jdoe  # e.g.; $HOME was expanded, as expected\r\n\r\nPS> Write-Output -a$HOME\r\n-a$HOME  # !! $HOME was NOT expanded\r\n```\r\n\r\nNote that the problem only surfaces if the there's at least 1 literal char. following the `-` before the variable reference; for instance, in `-$HOME` the variable _is_ expanded.\r\n\r\n\r\nEnvironment data\r\n----------------\r\n\r\nWritten as of:\r\n\r\n```powershell\r\nPowerShell Core v6.0.2\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2018-03-22T20:14:21Z","url":"https://github.com/PowerShell/PowerShell/issues/6467"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:689b4ca0-d24e-4e1b-4009-56b662c7313d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idBA74:A76E8:134B6C:1A5AA1:6AFD4C9C
html-safe-nonce57c9d853d489560a41d750d775beb57002ad169a718a63b5cf00483773c99c6f
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQTc0OkE3NkU4OjEzNEI2QzoxQTVBQTE6NkFGRDRDOUMiLCJ2aXNpdG9yX2lkIjoiNzg3NTAyMTMyNjI1MjMxMDA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac9003db3bfca8b67b12e9e8e023b8f84341130b6f41f103060178c4ed82497896
hovercard-subject-tagissue:307798025
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/6467/issue_layout
twitter:imagehttps://opengraph.githubassets.com/4f7814b59a05899f37aefb48feed2214e651441c0e8fd638b5cb01662444ace8/PowerShell/PowerShell/issues/6467
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/4f7814b59a05899f37aefb48feed2214e651441c0e8fd638b5cb01662444ace8/PowerShell/PowerShell/issues/6467
og:image:altThe primary purpose of this issue to highlight how the existing behavior may be surprising to newcomers (and even for seasoned users hard to remember and therefore predict in specific situations). ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
None66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e
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
releaseb6f01f7cb9f35f8c09949773241a3d49dd04b340
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/6467#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F6467
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F6467
Sign uphttps://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/6467
Reloadhttps://github.com/PowerShell/PowerShell/issues/6467
Reloadhttps://github.com/PowerShell/PowerShell/issues/6467
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests365 (365)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/6467
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/6467
Parsing of compound command-line tokens into arguments is surprisinghttps://github.com/PowerShell/PowerShell/issues/6467#top
https://github.com/BrucePay
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Discussion%22
Resolution-AnsweredThe question is answered.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-Answered%22
WG-Languageparser, language semanticshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Language%22
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Mar 22, 2018https://github.com/PowerShell/PowerShell/issues/6467#issue-307798025
about_Parsinghttps://github.com/PowerShell/PowerShell-Docs/blob/staging/reference/6/Microsoft.PowerShell.Core/About/about_Parsing.md
Steve Lee (@SteveL-MSFT)https://github.com/SteveL-MSFT
Argument-mode parsing: Why is a subexpression at the start of an unquoted token treated differently than a variable reference? #3217https://github.com/PowerShell/PowerShell/issues/3217
documentation-repo issuehttps://github.com/PowerShell/PowerShell-Docs/issues
#6292https://github.com/PowerShell/PowerShell/issues/6292
#6360https://github.com/PowerShell/PowerShell/issues/6360
#4624https://github.com/PowerShell/PowerShell/issues/4624
https://github.com/BrucePay
Bruce Payette (BrucePay)https://github.com/BrucePay
on Mar 22, 2018https://github.com/PowerShell/PowerShell/issues/6467#issuecomment-375467747
Michael Klement (@mklement0)https://github.com/mklement0
Steve Lee (SteveL-MSFT)https://github.com/SteveL-MSFT
Documentation Needed in this repoDocumentation is needed in this repohttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Documentation%20Needed%20in%20this%20repo%22
on Mar 23, 2018https://github.com/PowerShell/PowerShell/issues/6467#event-1536898359
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Mar 26, 2018https://github.com/PowerShell/PowerShell/issues/6467#issuecomment-376287218
Bruce Payette (@BrucePay)https://github.com/BrucePay
Applying the hack consistentlyhttps://github.com/PowerShell/PowerShell/issues/6292#issuecomment-374009123
Bruce Payette (BrucePay)https://github.com/BrucePay
WG-Languageparser, language semanticshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Language%22
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Discussion%22
Resolution-AnsweredThe question is answered.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-Answered%22
on Mar 30, 2018https://github.com/PowerShell/PowerShell/issues/6467#event-1549036952
Bruce Payette (BrucePay)https://github.com/BrucePay
on May 3, 2018https://github.com/PowerShell/PowerShell/issues/6467#event-1606743608
Joey Aiello (joeyaiello)https://github.com/joeyaiello
Documentation Needed in this repoDocumentation is needed in this repohttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Documentation%20Needed%20in%20this%20repo%22
on Oct 15, 2018https://github.com/PowerShell/PowerShell/issues/6467#event-1905293985
https://github.com/joeyaiello
Joey Aiello (joeyaiello)https://github.com/joeyaiello
on Oct 31, 2018https://github.com/PowerShell/PowerShell/issues/6467#issuecomment-434840952
Michael Klement (@mklement0)https://github.com/mklement0
MicrosoftDocs/PowerShell-Docs#3038https://github.com/MicrosoftDocs/PowerShell-Docs/issues/3038
Michael Klement (mklement0)https://github.com/mklement0
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 31, 2018https://github.com/PowerShell/PowerShell/issues/6467#event-1939043613
https://github.com/UberKluger
UberKlugerhttps://github.com/UberKluger
on Jun 13, 2021https://github.com/PowerShell/PowerShell/issues/6467#issuecomment-860232907
Michael Klement (@mklement0)https://github.com/mklement0
Bruce Payette (@BrucePay)https://github.com/BrucePay
Bruce Payette (@BrucePay)https://github.com/BrucePay
Bruce Payette (@BrucePay)https://github.com/BrucePay
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on Jun 13, 2021https://github.com/PowerShell/PowerShell/issues/6467#issuecomment-860248748
UberKlugerhttps://github.com/UberKluger
bucket 3https://github.com/PowerShell/PowerShell/blob/master/docs/dev-process/breaking-change-contract.md#bucket-3-unlikely-grey-area
create an issue in the documentation repohttps://github.com/MicrosoftDocs/PowerShell-Docs/issues/new/choose
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/6467
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/6467
Bruce Payette (BrucePay)https://github.com/BrucePay
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Discussion%22
Resolution-AnsweredThe question is answered.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-Answered%22
WG-Languageparser, language semanticshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Language%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.