On Thu, Jan 10, 2013 at 02:44:42AM -0500, sacrificial-spam-addr...@horizon.com wrote: > > Thanks, I fixed this now in my bzr tree and it will be part of the > > next upload. > > Er, assuming that's revision 2269: > http://anonscm.debian.org/loggerhead/apt/debian-sid/revision/2269/debian/apt.cron.daily
Great, thanks for double checking. > You don't need the final "cut -c1-5". It is true that cksum returns an > unsigned 32-bit number, and some shells only do 32-bit signed math, but > they simply convert the number to negative. > > You either mask off the sign bit with > RANDOM=$(($(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' > -f1) % 0x7fffffff)) > > Or, of you want to emulate the range of Bash $RANDOM exactly: > RANDOM=$(($(dd if=/dev/urandom bs=2 count=1 2> /dev/null | cksum | cut -d' ' > -f1) % 0x7fff)) Thanks, indeed, simulating this more closely is probably a good idea, I added that in my bzr branch now. > The "od -d -N2 -An" solution works with a recent enough od. > I was looking to see how old that can be. The uppercase option flags > are not in 7th edition, but are in POSIX.1 as of 2001: [..] Thanks for checking this. I like this, its more compact than the current code. However the reason why I did not use this, was that the following fragment: $ while true; do res=$(od -N2 -d /dev/urandom | cut -s -d' ' -f2); echo $res; if [ -z "$res" ]; then break; fi ; done 61581 42056 38021 $ give me a empty string in $res sometimes. I haven't really put any though into why this is, maybe just a side effect of running it in th while loop? Cheers, Michael -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org