Hi, On Thu, Jun 24, 2021 at 09:19:36PM -0700, Paul Eggert wrote: > On 6/24/21 4:46 PM, F8ER F8ER wrote: > >For example, `shuf -i 101-100 -n 1` returns nothing with the exit code > >= 0 (unexpected). > > Actually, it's the expected behavior. It's the same behavior as > 'shuf -n 1 </dev/null'. The '-n 1' option does not mean "output > exactly 1 line"; it means "output at most 1 line".
I think the reported issue is with producing no error with LO==HI+1, but producing an error with LO<HI+1: $ shuf -i 3-0 ; echo %exit code $? shuf: invalid input range: ‘3-0’ %exit code 1 $ 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. I have taken this example with an older "shuf" from my system, not the current upstream version: shuf --version | head -n1 shuf (GNU coreutils) 8.28 This is just intended to hopefully clear up a possible misunderstanding, not to confirm or falsify if the current "shuf" version behaves in the same way. HTH, HAND, Erik -- Object-oriented design is the roman numerals of computing. -- Rob Pike