busybox/coreutils
Denys Vlasenko 9de9c871bf shuf: fix random line selection. Closes 9971
"""
For example, given input file:

    foo
    bar
    baz

after shuffling the input file, foo will never end up back on the first line.
This came to light when I ran into a use-case where someone was selecting
a random line from a file using shuf | head -n 1, and the results on busybox
were showing a statistical anomaly (as in, the first line would never ever
be picked) vs the same process running on environments that had gnu coreutils
installed.

On line https://git.busybox.net/busybox/tree/coreutils/shuf.c#n56 it uses
r %= i, which will result in 0 <= r < i, while the algorithm specifies
0 <= r <= i.
"""

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-07-09 00:39:15 +02:00
..
libcoreutils libbb: more compact API for bb_parse_mode() 2015-10-07 17:55:33 +02:00
basename.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
cat.c catv: convert this bbox-specific applet into "cat -v" 2017-04-12 17:17:29 +02:00
chgrp.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
chmod.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
chown.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
chroot.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
cksum.c shred: new applet 2017-04-07 20:45:08 +02:00
comm.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
Config.src Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
cp.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
cut.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
date.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
dd.c dd: call fsync() only once before exiting if conv=fsync is specified 2017-03-16 20:54:35 +01:00
df.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
dirname.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
dos2unix.c Spelling fixes in comments, documentation, tests and examples 2017-04-17 16:13:32 +02:00
du.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
echo.c shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo 2017-01-10 15:13:30 +01:00
env.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
expand.c *: add comment about APPLET_ODDNAME format 2017-01-29 14:57:33 +01:00
expr.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
factor.c factor: fix stray semicolon 2017-04-17 15:57:07 +02:00
false.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
fold.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
fsync.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
head.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
hostid.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
id_test.sh
id.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
install.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
Kbuild.src shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo 2017-01-10 15:13:30 +01:00
link.c link: new applet 2017-01-26 00:27:53 +01:00
ln.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
logname.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
ls.c ls: fix support for long options when FEATURE_LS_COLOR is deselected 2017-05-26 16:50:53 +02:00
md5_sha1_sum.c tls: add 2nd cipher_id, TLS_RSA_WITH_AES_128_CBC_SHA, so far it doesn't work 2017-01-24 16:00:54 +01:00
mkdir.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
mkfifo.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
mknod.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
mktemp.c Sort more misplaced applets into coreutils or util-linux 2017-04-12 14:16:29 +02:00
mv.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
nice.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
nl.c nl: fix copyright message 2017-04-09 21:19:29 +02:00
nohup.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
nproc.c nproc: new applet 2017-04-07 21:47:53 +02:00
od_bloaty.c getopt32: add new syntax of 'o:+' and 'o:*' for -o NUM and -o LIST 2016-07-06 21:58:02 +02:00
od.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
paste.c whitespace fix 2017-03-24 15:00:12 +01:00
printenv.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
printf.c shells: make hush test optional, rename ASH_BUILTIN_foo -> ASH_foo 2017-01-10 15:13:30 +01:00
pwd.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
readlink.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
realpath.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
rm.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
rmdir.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
seq.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
shred.c shred: smaller code 2017-04-07 21:10:00 +02:00
shuf.c shuf: fix random line selection. Closes 9971 2017-07-09 00:39:15 +02:00
sleep.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
sort.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
split.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
stat.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
stty.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
sum.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
sync.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
tac.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
tail.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
tee.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
test_ptr_hack.c *: make GNU licensing statement forms more regular 2010-08-16 20:14:46 +02:00
test.c libbb: new function bb_getgroups() - allocating wrapper around getgroups() 2017-07-04 18:56:45 +02:00
timeout.c Sort some miscutils/ applets into coreutils or util-linux 2017-04-12 13:58:40 +02:00
touch.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
tr.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
true.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
truncate.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
tty.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
uname.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
uniq.c Add help text for 'uniq -i' 2017-04-05 18:51:27 +02:00
unlink.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
usleep.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
uudecode.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
uuencode.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
wc.c Big cleanup in config help and description 2017-01-10 14:58:54 +01:00
who.c fix errors found with make_single_applets.sh 2017-04-12 15:48:19 +02:00
whoami.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00
yes.c Convert all coreutils/* applets to "new style" applet definitions 2016-11-23 14:46:56 +01:00