[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#49217: 'shuf' returns nothing if the low range number is higher by 1
bug#49217: 'shuf' returns nothing if the low range number is higher by 1 than the high number
Fri, 25 Jun 2021 09:29:04 -0700
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0
On 6/24/21 11:49 PM, Erik Auerswald wrote:
$ shuf -i 2-0 ; echo %exit code $?
shuf: invalid input range: ‘2-0’
%exit code 1
$ shuf -i 1-0 ; echo %exit code $?
%exit code 0
This looks inconsistent and possibly not exactly as intended.
It's exactly what I intended and there's no inconsistency. When you say
'shuf -i M-N' you select from a collection of N-M+1 lines. N-M+1 = 0 (no
input lines) makes sense, but N-M+1 < 0 (negative number of input
lines?) does not.
I'd like to
document it and add test cases.
Feel free, though we need to reserve the right to extend 'shuf' in the
future. In other words, not every invocation of 'shuf' that provokes a
diagnostic now will provoke a diagnostic in the future.
bug#49217: [PATCH] shuf: fix bug with "-i 1-0", Erik Auerswald, 2021/06/25
bug#49217: [PATCH] doc: clarify valid ranges for shuf -i, Erik Auerswald, 2021/06/26
bug#49217: [PATCH] tests: exercise shuf --input-range edge cases, Erik Auerswald, 2021/06/26