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

Rework argument parsing in do/as providers #2813

Merged
merged 1 commit into from
Aug 14, 2023

Conversation

ferd
Copy link
Collaborator

@ferd ferd commented Jul 31, 2023

The current mechanism had a few oddities, as reported in #2811:

  • rebar3 do a,b runs a then b
  • rebar3 as profile task --a=b,c runs the task with the flag a set to b,c
  • rebar3 as profile task -a b,c runs the task with the flag a set to b, and then tries to run c as a task
  • rebar3 as profile task -a b, c runs the task with the flag a set to b, and then tries to run c as a task

So the issue is that to pass a comma to an argument, we can only do so when it exists as a long form argument (--flag) and that it does not contain spaces.

This patch attempts to correct things by making the white-space following the comma significant. If it's missing, it gets grouped as a single entity. If it's there, the task is considered to be split.

This becomes significant for commands that internally parse the , to allow list of args (such as rebar3 release --relnames one,two) which were only invokable as --relnames=one,two, and not the spaced version nor the short version (-m one,two), which should now be supported. Also do note that we seemingly deal with quoting fine, and so rebar3 do release --relnames "a, b" will prevent the whitespace from splitting the argument into commands.

This should not break any backwards compatibility, but there is the possibility that users who did invoke many commands with both arguments and sequences without spaces (rebar3 do release --relname a,tar) now get broken commands.

I don't quite know if we'd be okay taking that risk, so this is up for comments I guess.

The current mechanism had a few oddities, as reported in
erlang#2811:

- `rebar3 do a,b` runs `a` then `b`
- `rebar3 as profile task --a=b,c` runs the task with the flag `a` set
  to `b,c`
- `rebar3 as profile task -a b,c` runs the task with the flag `a` set to
  `b`, and then tries to run `c` as a task
- `rebar3 as profile task -a b, c` runs the task with the flag `a` set to
  `b`, and then tries to run `c` as a task

So the issue is that to pass a comma to an argument, we can only do so
when it exists as a long form argument (`--flag`) and that it does not
contain spaces.

This patch attempts to correct things by making the white-space
following the comma significant. If it's missing, it gets grouped as a
single entity. If it's there, the task is considered to be split.

This becomes significant for commands that internally parse the `,` to
allow list of args (such as `rebar3 release --relnames one,two`) which
were only invokable as `relnames=one,two`, and not the spaced version
nor the short version (`m one,two`), which should now be supported.

This should *not* break any backwards compatibility, but there is the
possibility that users who did invoke many commands with both arguments
and sequences without spaces (`rebar3 do release --relname a,tar`) now
get broken commands.

I don't quite know if we'd be okay taking that risk, so this is up for
comments I guess.
@ferd ferd force-pushed the rework-arg-parsing-commas-in-do-as branch from 3f4d49b to 3051e66 Compare July 31, 2023 23:15
@ferd ferd merged commit 11c2de0 into erlang:main Aug 14, 2023
6 checks passed
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.

None yet

1 participant