GNU bug report logs - #61267
shuf -i with negative numbers

Previous Next

Package: coreutils;

Reported by: <kpm <at> plan9.lol>

Date: Sat, 4 Feb 2023 07:46:02 UTC

Severity: normal

Tags: notabug

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 61267 in the body.
You can then email your comments to 61267 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#61267; Package coreutils. (Sat, 04 Feb 2023 07:46:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to <kpm <at> plan9.lol>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Sat, 04 Feb 2023 07:46:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: <kpm <at> plan9.lol>
To: <bug-coreutils <at> gnu.org>
Subject: shuf -i with negative numbers
Date: Fri, 03 Feb 2023 23:31:06 +0100
hello

shuf -i option cannot handle negative numbers.
examples:
  $ shuf -i -10-20
  $ shuf -i 0--20

don't know if it's a bug or a feature.

:^)
~ kpm




Information forwarded to bug-coreutils <at> gnu.org:
bug#61267; Package coreutils. (Sat, 04 Feb 2023 12:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 61267 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: kpm <at> plan9.lol, 61267 <at> debbugs.gnu.org
Subject: Re: bug#61267: shuf -i with negative numbers
Date: Sat, 4 Feb 2023 12:09:25 +0000
tag 61267 notabug
close 61267
stop

comments below...

On 03/02/2023 22:31, kpm <at> plan9.lol wrote:
> hello
> 
> shuf -i option cannot handle negative numbers.
> examples:
>    $ shuf -i -10-20
>    $ shuf -i 0--20
> 
> don't know if it's a bug or a feature.

The input range needs to be unsigned
as documented in the info manual.
It should be easy enough to shift to the desired range,
for example:

  $ shiftn() { sed "s/\$/$1/" | bc; }
  $ shuf -i 0-10 | shiftn -5
  3
  -2
  0
  5
  2
  -5
  4
  -1
  -3
  1
  -4

cheers,
Pádraig




Added tag(s) notabug. Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Sat, 04 Feb 2023 12:10:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 61267 <at> debbugs.gnu.org and <kpm <at> plan9.lol> Request was from Pádraig Brady <P <at> draigBrady.com> to control <at> debbugs.gnu.org. (Sat, 04 Feb 2023 12:10:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 04 Mar 2023 12:24:15 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 169 days ago.

Previous Next


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