GNU bug report logs - #49217
'shuf' returns nothing if the low range number is higher by 1 than the high number

Previous Next

Package: coreutils;

Reported by: F8ER F8ER <the.f8er <at> gmail.com>

Date: Fri, 25 Jun 2021 04:14:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: F8ER F8ER <the.f8er <at> gmail.com>
Subject: bug#49217: closed (Re: bug#49217: 'shuf' returns nothing if the
 low range number is higher by 1 than the high number)
Date: Fri, 25 Jun 2021 04:20:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#49217: 'shuf' returns nothing if the low range number is higher by 1 than the high number

which was filed against the coreutils package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 49217 <at> debbugs.gnu.org.

-- 
49217: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=49217
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Paul Eggert <eggert <at> cs.ucla.edu>
To: F8ER F8ER <the.f8er <at> gmail.com>
Cc: 49217-done <at> debbugs.gnu.org
Subject: Re: bug#49217: 'shuf' returns nothing if the low range number is
 higher by 1 than the high number
Date: Thu, 24 Jun 2021 21:19:36 -0700
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".

[Message part 3 (message/rfc822, inline)]
From: F8ER F8ER <the.f8er <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: 'shuf' returns nothing if the low range number is higher by 1 than
 the high number
Date: Fri, 25 Jun 2021 01:46:30 +0200
Dear GNU Developers,


Thank you very much for the project.


It seems, if the low range number is higher by 1 than the high number,
the program returns

nothing (with exit code = 0), while 102-100 results in an error and
100-100 returns 100 as expected.

For example, `shuf -i 101-100 -n 1` returns nothing with the exit code
= 0 (unexpected).


Expected (normal):

`shuf -i 100-101 -n 1` returns either 100 or 101 with an exit code = 0.

`shuf -i 100-100 -n 1` returns 100 with an exit code = 0.

`shuf -i 102-100 -n 1` results in an error with an exit code = 1.


Is that an expected behavior?


Stay safe!


Best and kind regards



This bug report was last modified 3 years and 327 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.