Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Nov 16, 2018

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 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
Contributor

@bergmeister bergmeister left a 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?

@SteveL-MSFT
Copy link
Member Author

@bergmeister good point, I'll update

address Chris' comment
@TravisEz13 TravisEz13 merged commit b7daa79 into PowerShell:master Nov 19, 2018
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 SteveL-MSFT deleted the trailing-quote branch June 6, 2020 02:28
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