-
Notifications
You must be signed in to change notification settings - Fork 154
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
Fixed command parsing with -e
option
#961
Conversation
The executable command (that comes after Now, in addition to
All following combinations also work with QTerminal, as they work with xterm:
|
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.
Great improvements! Haven't checked details, but I suspect parse_command()
may be fragile to future changes. Could you add unit tests? I will find time to setup CI for this repo.
I added a commit for raw string literals. Unfortunately, I don't have time to add unit tests here — maybe later and in another PR — but, for example, if FeatherPad is installed, the patch can be tested by creating a text file
Of course, the home path can be replaced by
|
Strange that I didn't see this important comment! @yan12125, IMHO, it isn't fragile — because it isn't about the changes in Qterminal — it's either correct or incorrect. Maybe by "fragile" you meant "dirty". As far as I've seen, parsing codes are usually dirty, because of their complex logic. |
By fragile, I mean if someone else wants to modify that function to support more command patterns, parsing for existing patterns may get broken (regression). Adding tests ensures that won't happen. I can try to turn current examples into tests this week. |
Yes, because of its complex logic. By "complex", I mean a bad thing, which I think is inevitable in this case. A worse example of it can be found in https://github.com/lxqt/libqtxdg/blob/master/src/qtxdg/xdgdesktopfile.cpp. |
A good news is that comes with tests ;) https://github.com/lxqt/libqtxdg/blob/master/test/tst_xdgdesktopfile.cpp |
I never said I'm against adding tests — why should I? I just can't add them myself, due to lack of time. |
Added tests ;) By the way, during testing, I noticed that xterm lets the shell to handle complex commands. That might be simpler and more reliable.
See: https://github.com/ThomasDickey/xterm-snapshots/blob/master/main.c#L5141 |
(Rebased so that tests are run on CI) |
Thanks for the commits!
Interesting, and worth experimenting. |
As for xterm, I remember that its behavior (not its code) was my criterion. In some complex cases (which I don't remember), Konsole's behavior was different from that of xterm and QTermnal, but they were too artificial. That being said, counterexamples are very welcome. |
Speaking of complex cases, there is a difference between this pull request and xterm:
Anyway, I think it's OK to have different results for complex cases. It's fine as long as parsing logic is reasonable and consistent. PS. I use zsh, so xterm calls zsh to parse the command as shown in my earlier comment. |
I use bash and the behaviors are exactly the same. I think you've found a problem (or inconsistency) in zsh ;) |
Interesting! So parsing arguments within qterminal is better. That avoids differences among shells. |
I think this can be merged now? |
I think there's no strict standard. Here, I just followed the rules that I considered "obvious". Of course, they could be changed if needed.
IMHO, the sooner git users have it, the better. The next release will be made soon. |
Sure!
Oh, good reminder! Let me merge this first and check other PRs. |
By using
QStringList
instead ofQString
.Fixes #335 and fixes #665