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

cut-huge-range.sh: make cut fails on usize::MAX #4988

Merged
merged 2 commits into from
Sep 26, 2023

Conversation

sylvestre
Copy link
Contributor

GNU fails with
$ cut -b18446744073709551615 /dev/null
but we are able to support this value

we both fail with
$ cut -b18446744073709551616 /dev/null

@github-actions
Copy link

GNU testsuite comparison:

Congrats! The gnu test tests/misc/cut-huge-range is no longer failing!

Copy link
Contributor

@cakebaker cakebaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason to adjust the test instead of our code?

@tertsdiepraam
Copy link
Member

tertsdiepraam commented Jun 20, 2023

My theory for why we support this and GNU doesn't is that we might be using an inclusive range internally and that GNU would be using an exclusive range internally, parsed from an inclusive range.

If everything else works as expected I don't see a reason explicitly break support for that single value.

For context, though that might be obvious, the value in the GNU test is u64::MAX. Using an exclusive range with a u64 would mean that the largest value in that range is u64::MAX - 1. With an inclusive range it's u64::MAX.

@sylvestre
Copy link
Contributor Author

Honestly, I don't know why it is done this way.

I am not sure how to update the parsing code to do this:

fn from_str(s: &str) -> Result<Self, &'static str> {

@sylvestre sylvestre force-pushed the cut-huge branch 2 times, most recently from 078c494 to 0cb60d1 Compare September 24, 2023 21:16
@sylvestre sylvestre changed the title cut-huge-range.sh: adjust the test as we don't fail cut-huge-range.sh: make cut fails on usize::MAX Sep 24, 2023
@sylvestre
Copy link
Contributor Author

not sure why github action didn't comment but it passes:
2023-09-24T21:59:28.7735199Z PASS: tests/cut/cut-huge-range.sh

@sylvestre sylvestre merged commit 7ebdab6 into uutils:main Sep 26, 2023
@sylvestre sylvestre deleted the cut-huge branch September 26, 2023 09:37
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.

3 participants