-
Notifications
You must be signed in to change notification settings - Fork 68
Quote dash-prefixed path arguments in PowerShell wrapper #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,16 @@ function PSConsoleHostReadLine { | |
| $argsStart = $wordEnd | ||
| # IndexOfAny beats running the regex per arg. | ||
| if ($source.IndexOfAny($script:__COREUTILS_ARG_SPECIAL__) -lt 0) { | ||
| # PowerShell's Legacy native argument mode can split extension-like | ||
| # parameter tokens (e.g. -dash.txt -> -dash + .txt) for .cmd | ||
| # targets. Quote these tokens while leaving ordinary bare globs | ||
| # unquoted so coreutils can still expand them. | ||
| if ($source -match '^-[^-][^\s]*\.[^\s]*$' -and | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This regex will match
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is excellent, but I hesitate to merge it for a similar reason: I find it hard to reason about why PowerShell fails this way and how we can fix it in the most robust manner.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Your concern is right,this regex is too loose.I will improve it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, we need to find out the reason first. An end-to-end test would help ensure correctness, but I agree that we need a deeper understanding of why PowerShell splits these tokens before we can design a robust fix. I'll investigate further.
This comment was marked as duplicate.
Sorry, something went wrong. |
||
| $source.IndexOfAny([char[]]@('*', '?', '[', ']')) -lt 0) { | ||
| $rewrittenArgs += "'" + ((__coreutils_q $source).Replace("'", "''")) + "'" | ||
| $i++ | ||
| continue | ||
| } | ||
| $rewrittenArgs += $source | ||
| $i++ | ||
| continue | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.