-
Notifications
You must be signed in to change notification settings - Fork 701
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
Fix splitArgs function. #8093
base: master
Are you sure you want to change the base?
Fix splitArgs function. #8093
Conversation
Just in case you didn't see: There's a second CI failure in the package config roundtrip tests, which I can't quite make sense of, but they're all of the form
(As I understand it that's generated as a valid config, but no longer parseable. Not sure that should be a valid config...) |
At least cabal reject that config with the same error that we see in the CI, so it's not a valid config. We are getting this error while shrinking which means something else failed before. I disabled shrinking and got an error which is related to this pr i.e. single quotes have to be paired now. This is the failure: -- new behaviour
> splitArgs "G%D PP X#' # njJ"
["G%D","PP","X# # njJ"]
-- old behaviour
> splitArgs "G%D PP X#' # njJ"
["G%D","PP","X#'","#","njJ"] We need to decide what to do here |
e437dff
to
3303a22
Compare
I'm getting
so indeed, on commandline single quotes need to be matched and are special, so IMHO we are fine to treat them as such in commandline arguments, whether really coming from commandline or written in config files, etc. |
For completeness the above test in win cmd gives diff results:
the behaviour in powershell is the same as sh: PS D:\> echo don't
>> ^C
PS D:\d> echo don't'
dont we could use sh in windows wth msys2 and the behaviour will be the same of course |
Oh dear. But with double quotes it works the same as in POSIX? If so, this means cabal should only use double quotes when calling GHC and other tools, to be usable with Windows cmd. But I think, for simplicity, it should still assume POSIX for commandline that for any reason contains single quotes, e.g., because the user wrote them, as in this case. |
Nobody objected, so I'd say, let's run with the current design. On Windows, people would be restricted to double quotes, but oh well. Let me rebase, because we've cleaned up CI, so the state of this PR should be more apparent now. |
@Mergifyio rebase |
✅ Branch has been successfully rebased |
3303a22
to
db1e69b
Compare
Nah, it seems GHC just cancels all tests after the single failure we discussed how to fix. Let's do it. :) |
But just in case let me rebase again, after GHA fixed itself and we tweaked something in CI again. |
@Mergifyio rebase |
✅ Branch has been successfully rebased |
db1e69b
to
dbb1afb
Compare
I'm curious: what is the status of this? Is it ready for prime time? |
It's one tiny fix away from prime time, I hope. |
@Mikolaj which one? You said above: "Nobody objected, so I'd say, let's run with the current design." and then rebased it a couple time, so I thought this patch already implements what has been agreed upon? There was a CI error but the author mentioned that cabal also fails in that case. |
Let me try to recall. I think you are right the current behaviour is fine, which means the fix should be to the testsuite so that it accepts the current behaviour (with some explanation somewhere, in the worst case just a comment in a test). |
Does anyone understand the doctest failure:
Superficially, it seems like the results are the same but there's a difference in the way lists are outputted... Am I missing something? |
@ulysses4ever AFAIK doctest does a literal string equality check, it looks like there should be no space in between the elements |
@mergify rebase |
✅ Branch has been successfully rebased |
dbb1afb
to
662b63a
Compare
d0d22fb
to
247d3f2
Compare
I fixed the failing test and would appreciate reviews to hopefully get it done finally. |
✅ Branch has been successfully rebased |
9423d64
to
b84979d
Compare
@robx: are your comments taken into account? |
@pranaysashank: do you like the tweaks and the final form of this PR? |
@Mikolaj yes it looks fine and thanks @ulysses4ever for fixing the tests. I am no longer confident that this is a bug, or that this PR is the correct way to fix it. With this PR I don't think we can any longer pass
And ways of escaping a single quote seems non trivial, so I think this PR only adds more confusion to the existing situation |
Ouch. I wonder what is the prevailing mode of operation of old and new Unix commandline utilities in such cases. Which quotes are used for grouping and if/how they escape them. |
Given that
it is probably understood that to have literal
So maybe this pr is fine idk 🤷 . Once we have a way to pass arguments to test executables similar to how we pass them to run executables these issues will likely become even less relevant. Edit: |
People trip over this in the wild, due their exposure to unix tools conventions. I think we should just follow these conventions, not try to evaluate them. The only problem is, we should follow them reasonably close.
I think it would be ideal if we had tests for these cases showing that cabal passes along the same strings
Could you elaborate? |
I have a guess: #7454 had a reasonable plan, I think. I was going to pick it up at some point (unless someone beats me to it). |
Yep, basically what @ulysses4ever said. Right now when we do cabal run we pass arguments as
We can do the same for test
I don't think they go through splitArgs and also are not quoted like with |
Oh, yes. In fact, the I think |
Actually, now that I think about it, |
What does |
Indeed. It probably gives the arguments to all text exes, but I haven't checked. We don't yet have |
This has been discussed (at least) in #5416. The outcome was, in my interpretation, is that there's already --test-option that suffers the same, yet being usable. So it won't hurt (and probably benefit several people who keep opening issues like that) to have |
Right. So I think we need both. |
I created a simple project with a test suite, which prints out what it gets as the arguments: There are good news and bad news. Let's start with bad:
So, the trailing quote ( Good news:
Note you can try it yourself with cabal built in the CI for this PR: RE comparison to Unix tools, e.g. echo. I'm not sure it's very easy to compare. E.g. is
(recall, with the patch it kills the quote and you get
I understand you argue its the former (it's as if the test gets a "naked" As the bottomline, I'm torn... Perhaps, eating quotes will break someone's testing code. Whereas, the '-inside-" vs. "-inside-' difference (the original motivation in 8090) could perhaps be just documented. And if we do pull out the proper behavior for |
I am inclined towards not introducing the breaking change in this PR, and just document this in the |
This is a very in-depth discussion. I totally defer to your judgement @pranaysashank and @ulysses4ever. If you endeavour to fix the help texts, pretty please include also the |
Marking this PR as draft 🙂 |
TODO
Please include the following checklist in your PR:
Please also shortly describe how you tested your change. Bonus points for added tests!