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

Fixe arg parsing when one-character argument is followed by ; #13706

Merged
2 commits merged into from
Aug 12, 2022

Conversation

serd2011
Copy link
Contributor

@serd2011 serd2011 commented Aug 9, 2022

Summary of the Pull Request

Changes the way _addCommandsForArg determines if the delimiter was at the beginning of the argument so that it accounts for the fact that match includes the last character of the string before it.

PR Checklist

Validation Steps Performed

wt -p "u"; nt -p "u" does not cause an error

@ghost ghost added Area-Commandline wt.exe's commandline arguments Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Aug 9, 2022
@serd2011 serd2011 changed the title Fixes command-line args parsing when one-character argument is followed by '; Fixes command-line args parsing when one-character argument is followed by ; Aug 9, 2022
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love a test for this in src\cascadia\LocalTests_TerminalApp\CommandlineTest.cpp, but the LocalTests are kinda finicky to get running so I won't cry if this merges without one.

@serd2011
Copy link
Contributor Author

Would it be ok add them to ParseTrickyCommandlines or ParseSimpleCommandline?
Is testing that one-character argument parsed correctly enough or are there more test cases that need to be added?

@zadjii-msft
Copy link
Member

ParseTrickyCommandlines seems fine to me ; the wt -p "u"; nt -p "u" test case seems good enough of a test to me 😄

@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Aug 12, 2022
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Future improvement:) Looking at _commandDelimiterRegex, I get the feeling that this code would be a lot more robust if we'd just find(L';') and check if the preceding character is != L'\\'.

@DHowett
Copy link
Member

DHowett commented Aug 12, 2022

(Future improvement:) Looking at _commandDelimiterRegex, I get the feeling that this code would be a lot more robust if we'd just find(L';') and check if the preceding character is != L'\\'.

Yes and no.

What if the character before the \ is \? \\; is not the same as \;!

@lhecker
Copy link
Member

lhecker commented Aug 12, 2022

What if the character before the \ is \? \\; is not the same as \;!

The regex is currently (^;|[^\\];) and described as

Either a ; at the start of a line, or a ; preceded by any non-\ char.

There's nothing in the regex that would handle such a case. If we handle it, it must be elsewhere or not at all...

@DHowett
Copy link
Member

DHowett commented Aug 12, 2022

This vaguely worries me, actually. Why are we using a regex to match a character followed by ; when what we want to know is whether there is a ;? Is it just because we need to match anything except a \?

Leonard's right, we should be using a more direct/implementation-specific string parser rather than a regex. It would give us control over exactly when we match and when we "vend". :)

@DHowett DHowett changed the title Fixes command-line args parsing when one-character argument is followed by ; Fixe arg parsing when one-character argument is followed by ; Aug 12, 2022
@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Aug 12, 2022
@ghost
Copy link

ghost commented Aug 12, 2022

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit 1b3d004 into microsoft:main Aug 12, 2022
@ghost
Copy link

ghost commented Sep 13, 2022

🎉Windows Terminal Preview v1.16.252 has been released which incorporates this pull request.:tada:

Handy links:

@ghost ghost mentioned this pull request Sep 13, 2022
This pull request was closed.
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 AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Second It's a PR that needs another sign-off Priority-2 A description (P2) Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

--profile: 1 required TEST missing
4 participants