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 
	 
	
	
	
		  ..
	 
	
	
		
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-12 17:17:29 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-07 20:45:08 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-03-16 20:54:35 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-17 16:13:32 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 15:13:30 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-29 14:57:33 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-17 15:57:07 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 15:13:30 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-26 00:27:53 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-05-26 16:50:53 +02:00 
		 
	
		
			
			
			
			
			
			2017-01-24 16:00:54 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-12 14:16:29 +02:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-09 21:19:29 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-07 21:47:53 +02:00 
		 
	
		
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-03-24 15:00:12 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 15:13:30 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-07 21:10:00 +02:00 
		 
	
		
			
			
			
			
			
			2017-07-09 00:39:15 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
	
		
			
			
			
			
			
			2017-07-04 18:56:45 +02:00 
		 
	
		
			
			
			
			
			
			2017-04-12 13:58:40 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-05 18:51:27 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2017-01-10 14:58:54 +01:00 
		 
	
		
			
			
			
			
			
			2017-04-12 15:48:19 +02:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00 
		 
	
		
			
			
			
			
			
			2016-11-23 14:46:56 +01:00