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

nothing before -- should appear in ARGS #12679

Closed
rened opened this issue Aug 18, 2015 · 9 comments
Closed

nothing before -- should appear in ARGS #12679

rened opened this issue Aug 18, 2015 · 9 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@rened
Copy link
Member

rened commented Aug 18, 2015

I find the current behavior of command line argument parsing a bit in-consistent:

> julia -e "@show ARGS; using Watcher" -- julia RUN.jl
ARGS = UTF8String["julia","RUN.jl"]

> julia -e "@show ARGS; using Watcher" -now -- julia RUN.jl
ARGS = UTF8String["@show ARGS; using Watcher","-now","julia","RUN.jl"]

It seems that, as -- is optional, unknown parameters (like the -now) end up in ARGS despite them being before the --. That "@show ARGS..." ends up in ARGS is a bug IMHO.

To simplify the situation, I would like to propose to make the -- compulsory, i.e. nothing before -- can ever appear in ARGS.

@jakebolewski
Copy link
Member

No, -- will never be compulsory. This is just wrong behavior.

@rened
Copy link
Member Author

rened commented Aug 18, 2015

Ok, but would you agree that in case -- is present, nothing before -- should appear in ARGS?

@jakebolewski
Copy link
Member

Yes.

@rened
Copy link
Member Author

rened commented Aug 18, 2015

Ok, I'll try to track this down then and submit a PR.

@jakebolewski
Copy link
Member

Cool. The relevant code is in client.jl in process_options. ARGS should be assigned a copy of all string arguments after the -- delimiter. Right now it is just getting removed.

@rened
Copy link
Member Author

rened commented Aug 18, 2015

Thanks for the lead!

@jakebolewski
Copy link
Member

@rened if you are feeling ambitious, you could implement the behavior described here #10726 (comment). Although I suspect the one who implements the "correct" behavior will be the only one to actually use it.

@rened
Copy link
Member Author

rened commented Aug 18, 2015

@jakebolewski excellent, I also wanted to suggest to allow multiple --s. Will do.

@JeffBezanson JeffBezanson changed the title RFC: make '--' compulsory for ARGS nothing before -- should appear in ARGS Aug 20, 2015
@JeffBezanson JeffBezanson added the bug Indicates an unexpected problem or unintended behavior label Aug 20, 2015
@vtjnash
Copy link
Member

vtjnash commented Aug 20, 2015

To simplify the situation, I would like to propose to make the -- compulsory, i.e. nothing before -- can ever appear in ARGS.

that would not be standard unix behavior – argument parsing is expected to end on -- or the first unrecognized argument.

i agree that the disappearance of the -- from the ARGS list might be considered a bug (this is caused by the leading + to the getopt_long options string) as well as the inclusion of the argument string to -e in ARGS (it looks like the -n -o -w argument is confusing argument counting, possibly related to the leading character being + in the options string?)

for anyone who's investigating this further, I also discovered:

$ ./julia --compile=yes -foo
julia: unknown option `--compile=yes`

where the unknown option was -foo, not --compile

nolta added a commit that referenced this issue Sep 20, 2015
Moves all the cmdline option error handling code from client.jl to
repl.c.
jakebolewski added a commit that referenced this issue Sep 21, 2015
better cmdline option error handling (fixes #12679)
nolta added a commit that referenced this issue Oct 31, 2015
Moves all the cmdline option error handling code from client.jl to
repl.c.

(cherry picked from commit dff1c90)
ref #13245
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants