-
Notifications
You must be signed in to change notification settings - Fork 129
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 is accepting a decreasing range #467
Comments
It's an upstream bug. The arguments to Give me a moment and I'll apply a fix in busybox-w32. If that works out I'll send a patch upstream. |
The command 'cut -b 3-2' failed to detect that the bounds were incorrectly ordered, though the check worked when the difference between the bounds was larger. The comparison was made after the lower bound has been decremented but before the upper bound had. Adds 0-16 bytes. (GitHub issue #467)
OK, try the latest prerelease (PRE-5519 or above). |
Sorry to be late, the code seems to works but the error message is completely off:
If it require additional code to have the numbers in the error message correct maybe just remove them is also fine. |
Commit 0068ce2 (cut: add toybox-compatible options -O OUTSEP, -D, -F LIST) added detection of reversed ranges. Further improvements are possible. - The test for reversed ranges compared the start after it had been decremented with the end before decrement. It thus missed ranges of the form 2-1. - Zero isn't a valid start value for a range. (Nor is it a valid end value, but that's caught by the test for a reversed range.) - The code if (!*ltok) e = INT_MAX; duplicates a check that's already been made. - Display the actual range in the error message to make it easier to find which range was at fault. Adds 0-48 bytes. (GitHub issue #467)
I've made some further improvements to the detection of invalid ranges. Try the latest prerelease (PRE-5523 or above). |
It seems everything works perfectly, thanks. |
One minor thing. This: say: Since it no longer accept 0 the message should probably be changed. |
The message about the It's probably not worth the effort to do anything about it. |
There might be an internal len limit of |
Actually no, it is a fixed limit on BusyBox (from my tests). In the 64-bit cut (GNU coreutils) 8.32 the limit of |
and your test with 64 gnu cut reinforces the assessment that the limit is whatever_MAX - 1. But I misread the original message. The message is The message does appear correct, but your complaint is that the range should not start with 0 (to which I have no comment, also no comment on whether the limit is INT_MAX or INT_MAX-1). |
My latest comment was about a different issue. |
It does not. It's always 32 at least on Linux/Windows/macOS/most-unix. |
I'm not sure about all cases but INT_MAX is just a macro, so I think it depends from the compiler (and the libraries included with it) maybe. |
You can check here https://en.cppreference.com/w/cpp/language/types . |
Here it say otherwise: https://www.geeksforgeeks.org/int_max-int_min-cc-applications/ |
It doesn't. It says that IF it's 64 then it's not the same as 32. But I said that on Linux and Windows and macOS it's always 32. You can prove me wrong by showing me a linux distro where int is 64 bit. |
You may be right. |
While experimenting I have discovered a specific number that can make the "cut" of macOS freeze forever: |
This is correctly rejected:
echo 123 | cut -b '3-1'; echo $?
but this is currently allowed:
echo 123 | cut -b '3-2'; echo $?
Why is that?
cut included inside the setup of Bash under Windows reject both.
The text was updated successfully, but these errors were encountered: