Im having trouble generating random numbers with M4. I found a thread on the subject but the recommended defs do not work
>>m4 lacks a random number generator builtin. I think it would be great if such builtin existed. Currently I use something like: dnl random(num): Evaluates to a random number from range 0..num-1. define([random],[eval(esyscmd(printf $RANDOM) % $1)])dnl I have played and played with this, getting down to simple esyscmd and printf, but the $RANDOM shell command blows up in M4. So Im now down to these two commands to try to compare whats going on: esyscmd(`printf $user')dnl esyscmd(`printf $RANDOM')dnl and this is my output. mikezdnl printf: 1: usage: printf format [arg ...] Can anyone help me with why $RANDOM is not working in this context? If I run it standalone in a bash shell it kicks out a number just fine. even with the printf $RANDOM OR If anyone has a macro to generate random numbers, please post,the one from the thread above is not complete, either that or not compatable with M4 (2.0) and above... -- View this message in context: http://old.nabble.com/random-number-generator-tp29473901p29473901.html Sent from the Gnu - M4 - Discuss mailing list archive at Nabble.com.
