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

Stricter command line parsing #56294

Open
LilithHafner opened this issue Oct 22, 2024 · 6 comments
Open

Stricter command line parsing #56294

LilithHafner opened this issue Oct 22, 2024 · 6 comments
Labels
breaking This change will break code
Milestone

Comments

@LilithHafner
Copy link
Member

LilithHafner commented Oct 22, 2024

It would be nice if = was required instead of optional for flags with arguments. This would make the following behavior error:

x@x:~/test$ julia --trace-compile --banner=no
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.11.1 (2024-10-16)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> 
x@x:~/test$ ls
'--banner=no'
x@x:~/test$ cat -- --banner=no
precompile(Tuple{typeof(Base.print), Base.TTY, String})

Motivated by #56285

@LilithHafner LilithHafner added the breaking This change will break code label Oct 22, 2024
@LilithHafner LilithHafner added this to the Potential 2.0 milestone Oct 22, 2024
@fredrikekre
Copy link
Member

Could probably be folded into #29669

@mbauman
Copy link
Member

mbauman commented Oct 22, 2024

I think this is slightly different, and the minimal thing — erroring if a --flag arg is itself a flag without an explicit = — could be categorized as a UX bugfix.

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 23, 2024

Requiring an = prefix to filename arguments of options may break TAB completion of such filenames in some shells. That makes it desirable to not require any prefix for filenames on the command line, IMHO.

Try (e.g. in zsh):

% touch test-file
% julia --trace-compile test-f[TAB]
% julia --trace-compile=test-f[TAB]

(However, some shells, e.g. bash-5.0 on Ubuntu, have been configured to autocomplete after --blahfoo=...[TAB].)

@mbauman
Copy link
Member

mbauman commented Oct 23, 2024

I'm not suggesting requiring = in all situations. It would just be in the unlikely case that you want output precompiles (or whatever) to a file named --project.

@vtjnash
Copy link
Member

vtjnash commented Oct 23, 2024

We could error if the long opt value starts with -, but that would probably also still be breaking

@mgkuhn
Copy link
Contributor

mgkuhn commented Oct 23, 2024

Note that the POSIX standard says in Section 12.2 Utility Syntax Guidelines:

Guideline 6:
Each option and option-argument should be a separate argument, except as noted in Utility Argument Syntax, item (2).

The convention of optionally also allowing the --arg=param form of an option argument, in addition to the standard form --arg param comes from the GNU glibc function getopt_long() AFAIK, so that's what users are likely have come to expect from lots and lots of other existing command-line utilities using that popular command-line parser function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code
Projects
None yet
Development

No branches or pull requests

5 participants