Skip to content
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

Launching Windows Terminal with a file path that has a trailing backslash (in quotes) breaks the launch #9518

Closed
routerino opened this issue Mar 17, 2021 · 7 comments
Labels
Area-Commandline wt.exe's commandline arguments Issue-Question For questions or discussion Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered

Comments

@routerino
Copy link

routerino commented Mar 17, 2021

Environment

Windows build number: 10.0.19042.0
Windows Terminal version (if applicable): Believe this has happened on previous versions, but 1.7.572.0

Any other software?
Fresh install of Windows

Steps to reproduce

run wt -d "%userprofile%\" (edited, missed the -d parameter before)

Expected behavior

windows terminal handles trailing backslashes and still launches in the correct folder

Actual behavior

error 0x8007010b. Note that this does not happen if you leave out the quotes (but that will also break on folders with spaces)

Nkr4pXAc6T

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Mar 17, 2021
@skyline75489
Copy link
Collaborator

This isn't really about the backslash. You should use:

wt -d %userprofile%

@routerino
Copy link
Author

routerino commented Mar 17, 2021

Well that was a dumb error, but there's actually still a problem. Trying with wt -d "%userprofile%\" still breaks. However, wt -d %userprofile%\ does not. Reopening!

Nkr4pXAc6T

@routerino routerino reopened this Mar 17, 2021
@routerino routerino changed the title Launching Windows Terminal with a file path that has a trailing backslash breaks the launch Launching Windows Terminal with a file path that has a trailing backslash (in quotes) breaks the launch Mar 17, 2021
@KalleOlaviNiemitalo
Copy link

Perhaps this is caused by the "special interpretation of backslash characters when they are followed by a quotation mark character" in CommandLineToArgvW. Try doubling the backslash.

@routerino
Copy link
Author

Perhaps this is caused by the "special interpretation of backslash characters when they are followed by a quotation mark character" in CommandLineToArgvW. Try doubling the backslash.

That does appear to resolve the issue, but I don't think that's intended behavior. It does identify the problem though.

@zadjii-msft
Copy link
Member

That's exactly what the cause is:

wil::unique_any<LPWSTR*, decltype(&::LocalFree), ::LocalFree> argv{ CommandLineToArgvW(args.Commandline().c_str(), &argc) };

You might have better luck with wt -d "%userprofile%"\ instead - IIRC, CommandLineToArgv will still treat that as a single argument, and append the trailing slash.

@zadjii-msft zadjii-msft added Area-Commandline wt.exe's commandline arguments Issue-Question For questions or discussion Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered labels Mar 17, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 17, 2021
@routerino
Copy link
Author

routerino commented Mar 17, 2021

That's exactly what the cause is:

wil::unique_any<LPWSTR*, decltype(&::LocalFree), ::LocalFree> argv{ CommandLineToArgvW(args.Commandline().c_str(), &argc) };

You might have better luck with wt -d "%userprofile%"\ instead - IIRC, CommandLineToArgv will still treat that as a single argument, and append the trailing slash.

I'm not sure I'd consider that a solution. Most people are going to be adding a trailing slash on accident, not because they intentionally included it. These people will get confused by the error. I know it took me about 30 mins to track down why (a keyboard shortcut in multicommander to launch windows terminal in the open directory automatically adds a trailing slash).

Not going to reopen this myself, but I wouldn't consider that a satisfactory answer.

@DHowett
Copy link
Member

DHowett commented Mar 17, 2021

We briefly considered rewriting the argument parser, but we realized that doing so would bring us out of line with every other Windows application. Unfortunately, we're just not willing to do that. Sorry!

If there comes a day when we can do that without feeling like it breaks with established precedent, I'd be happy to do so 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Commandline wt.exe's commandline arguments Issue-Question For questions or discussion Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

5 participants