Skip to content

split: accept leading '+' in the number of chunks - #16019

Open
Logic769 wants to merge 3 commits into
uutils:mainfrom
Logic769:split-plus-number
Open

Logic769 wants to merge 3 commits into
uutils:mainfrom
Logic769:split-plus-number

Conversation

@Logic769

Copy link
Copy Markdown
Contributor

Problem

split -n +2 file fails with "invalid number of chunks" because the leading + is not stripped before parsing, whereas GNU split accepts it.

Change

In NumberType::from, strip an optional leading + before parsing the chunk count.

Tests

Added test_number_with_plus_prefix in tests/by-util/test_split.rs, checking that -n +2 splits the file into two chunks.

Closes #16006

Comment thread src/uu/split/src/strategy.rs Resolved
Comment thread tests/by-util/test_split.rs Resolved
Comment thread tests/by-util/test_split.rs Resolved
@Logic769

Copy link
Copy Markdown
Contributor Author

Pulled the + out in a helper before parse_size_u64 so every K/N is covered, and added l/+2 with content checks and r/+1/2.

Comment thread tests/by-util/test_split.rs Resolved
@sylvestre

Copy link
Copy Markdown
Contributor

a bunch of jobs are failing

This branch has not been deployed

No deployments
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.

split: -n +N is rejected

2 participants