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

split -1 in should be accepted #5033

Closed
sylvestre opened this issue Jul 3, 2023 · 8 comments · Fixed by #5252
Closed

split -1 in should be accepted #5033

sylvestre opened this issue Jul 3, 2023 · 8 comments · Fixed by #5252
Labels

Comments

@sylvestre
Copy link
Contributor

touch in
./target/debug/coreutils split -1 in

=>

error: unexpected argument '-1' found

  tip: to pass '-1' as a value, use '-- -1'

It should be equivalent to -a 1

@tertsdiepraam
Copy link
Member

Oh no, another shorthand?? 😄

@sylvestre
Copy link
Contributor Author

yeah :/ Do you know what is the best way to manage it now ? :)

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Jul 4, 2023

Not really, because every util has it's own version of it. Looking at some notes I took for my own argument parser, I noted that split allows the shorthand to appear in clusters of other short arguments. And they don't have it marked as deprecated and are using it actively in the examples: https://www.gnu.org/software/coreutils/manual/html_node/split-invocation.html nevermind that's just the n argument.

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Jul 4, 2023

Ah, so it works like uniq. This input:

split -x200x1 Cargo.lock LOCK

works like it's -l 2001. With uniq we decided to handle it like fold, where the number should be separate from the rest of the arguments. We could do the same here.

@zhitkoff
Copy link
Contributor

do you guys mind if I tackle this one?

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Aug 18, 2023

Go ahead! It might be a tricky one, but don't let that stop you :)

zhitkoff added a commit to zhitkoff/coreutils that referenced this issue Aug 18, 2023
zhitkoff added a commit to zhitkoff/coreutils that referenced this issue Aug 19, 2023
@zhitkoff
Copy link
Contributor

This is a bit more complicated than supporting split -1 in use case. The -1 obsolete option could also be found inside combined short options, like following (all below are valid and work with GNU split)
split -1dxe file which means split -l 1 -d -x -e file
split -ex23d file which means split -e -x -l 23 -d file
etc
Might need to refactor, so I will close pull request #5170 for now and resubmit a new one with code that would handle this broader use case.

@tertsdiepraam
Copy link
Member

I'd be fine with both cases. I think this is one of those cases where we just support what we can and hope that is satisfies everyone's use case. We've already spent so much time on these features 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment