Skip to content

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

Merged
sylvestre merged 3 commits into
uutils:mainfrom
Logic769:split-plus-number
Nov 7, 2026
Merged

sylvestre merged 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

@Logic769

Logic769 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Failure

Tests job: https://github.com/uutils/coreutils/actions/runs/41666866572/job/126024412687

The job fails while building the uucore doctests:

error: failed to determine package fingerprint for build script for uucore v0.13.0 (/home/runner/work/coreutils/coreutils/src/uucore)
...
  failed to determine the most recently modified file in /home/runner/work/coreutils/coreutils/src/uucore
...
  Failed to read the directory at '/home/runner/work/coreutils/coreutils/src/uucore/uucore_fs_test_identical_0'
  No such file or directory (os error 2)
...
error: doctest failed, to rerun pass `-p uucore --doc`

Reason

This is the known uucore test-directory race: filesystem tests create and remove temporary directories under src/uucore while Cargo is fingerprinting that package. The missing uucore_fs_test_identical_0 directory makes the fingerprint scan fail, which then cascades into missing extern locations and doctest failed. It is unrelated to the split leading-+ parsing change in this PR. Re-running the job should clear it.

@Logic769

Logic769 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Failure

The Tests job (126397657128) failed in Prepare, build and test while building the uucore doctests:

error: failed to determine package fingerprint for build script for uucore v0.13.0 (/home/runner/work/coreutils/coreutils/src/uucore)
Caused by:
  failed to determine the most recently modified file in /home/runner/work/coreutils/coreutils/src/uucore
Caused by:
  failed to determine list of files in /home/runner/work/coreutils/coreutils/src/uucore
Caused by:
  Failed to read the directory at '/home/runner/work/coreutils/coreutils/src/uucore/uucore_fs_test_sym_neq_2'
Caused by:
  No such file or directory (os error 2)

The subsequent E0463: can't find crate errors and doctest failed are cascades.

Reason

This is the same uucore test temp-directory race as in the earlier run: the filesystem tests create and remove src/uucore/uucore_fs_test_* directories while Cargo is scanning src/uucore to fingerprint its build script, so Cargo can observe a directory that disappears mid-scan. The failure is in the test harness, not in this PR's split changes, and there is no compile or assertion failure in the changed code.

Please rerun the Tests job.

@sylvestre
sylvestre merged commit 85fe9d6 into uutils:main Nov 7, 2026
101 of 103 checks passed
@sylvestre

Copy link
Copy Markdown
Contributor

Thanks for your PR

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