|
From: | Paul Eggert |
Subject: | bug#49217: 'shuf' returns nothing if the low range number is higher by 1 than the high number |
Date: | Fri, 25 Jun 2021 09:29:04 -0700 |
User-agent: | 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.
[Prev in Thread] | Current Thread | [Next in Thread] |