GeezerVison is showing github.com — Enable `Open Here` context menu on Windows to work with root of a drive by SteveL-MSFT · Pull Request #8287 · PowerShell/PowerShell
Conversation
PR Summary
The fundamental problem is that Microsoft cpp command line parsing rules indicate that a backslash followed by a quote is a quote, otherwise, it is literal. So this:
pwsh -noexit -workingdirectory "c:\"
Is received as c:" at argument parsing time. Of course, this is a bit more complicated as Open Here also uses -Command. So:
pwsh -noexit -workingdirectory "c:\" -command 1+1
Becomes c:" -command 1+1 as the argument value to -workingdirectory. And -command must be last in the command line.
Fix is to add a hidden switch for the purpose of the Open Here context menu called -RemoveWorkingDirectoryTrailingCharacter. This allows Open Here's command line to pad the path:
pwsh -noexit -removeworkingdirectorytrailingcharacter -workingdirectory "C:\!" -command 1+1
Now all the args can get parsed appropriately as the working directory path never ends with a trailing backslash.
Fix #8278
PR Checklist
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vexx32 reacted with hooray emoji
support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this problem is Windows specific wouldn't it make sense to expose -RemoveWorkingDirectoryTrailingCharacter only on Windows?
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
TravisEz13 reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Ilya (iSazonov)
pushed a commit
to iSazonov/PowerShell
that referenced
this pull request
Nov 29, 2018
…ve (PowerShell#8287)
support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
Thatgfsj (Thatgfsj)
pushed a commit
to Thatgfsj-contribs/PowerShell
that referenced
this pull request
Aug 6, 2026
…ve (PowerShell#8287)
support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
Reviewers
+1 more reviewer
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Labels
CL-BuildPackaging
Indicates that a PR should be marked as a build or packaging change in the Change Log
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|