Skip to content

Enable Open Here context menu on Windows to work with root of a drive - #8287

Merged
Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:trailing-quote
Nov 19, 2018
Merged

Travis Plunk (TravisEz13) merged 2 commits into
PowerShell:masterfrom
SteveL-MSFT:trailing-quote

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Nov 16, 2018 •

Copy link
Copy Markdown
Member

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

support being started by Windows Shell (Open Here) where a trailing slash followed by a quote is handled incorrectly
@iSazonov Ilya (iSazonov) added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Nov 16, 2018

Copy link
Copy Markdown
Contributor

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?

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

Christoph Bergmeister (@bergmeister) good point, I'll update

address Chris' comment
@TravisEz13
Travis Plunk (TravisEz13) merged commit b7daa79 into PowerShell:master Nov 19, 2018
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
@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the trailing-quote branch June 6, 2020 02:28
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PowerShell 6.1.1 - Context Menu "Open Here" gives error when path is root of drive

4 participants