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

preserve -- in ARGS when it follows a non-option argument #45335

Merged
merged 1 commit into from
May 17, 2022

Conversation

KristofferC
Copy link
Member

Rebase of #37010 since that PR does not allow updating the author's branch.

This is a proposed fix for #37009. It removes manual processing of -- and relies on getopt() to handle it correctly. The expected behavior:

  1. If -- appears before the first non-option argument, it forces the end of option processing and does not appear in ARGS.
  2. If -- appears after a non-option argument, it is preserved in ARGS. This -- has no effect on option processing since it's already stopped on the first non-option argument.

@KristofferC KristofferC added the merge me PR is reviewed. Merge when all tests are passing label May 17, 2022
@KristofferC KristofferC merged commit 1476e58 into master May 17, 2022
@KristofferC KristofferC deleted the kc/dashdash branch May 17, 2022 18:41
@giordano giordano removed the merge me PR is reviewed. Merge when all tests are passing label Jun 10, 2022
@mkitti
Copy link
Contributor

mkitti commented Feb 27, 2023

Interesting. This breaks how pyjulia installs PyCall.jl.

I'm a bit worried about how many other things this might break. Could we document this change better?

@MilesCranmer
Copy link
Member

Here's a summary of the issue we are seeing. Say that I execute the following statement:

julia --startup-file=no test.jl -- arg1 arg2

where test.jl contains println(ARGS). Before, I would get:

["arg1", "arg2"]

But after this PR, I get:

["--", "arg1", "arg2"]

@MilesCranmer
Copy link
Member

I wonder if there could simply be a warning displayed if -- is passed as a literal argument, at least for Julia 1.9? Perhaps a user could turn off the warning with some flag, indicating that they actually want to pass it. (It was quite hard to track down this error in PyJulia, I’m sure others will be hit as well.)

@KristofferC
Copy link
Member Author

Having a NEWS entry for this is indeed a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants