Re: random number generator

Eric Blake <[email protected]>
Newsgroups gmane.comp.gnu.m4.general
Organization Red Hat
Message-ID <[email protected]>
On 08/18/2010 03:08 PM, mikeyzman wrote:
>> It worked for me:
>>
>> $ m4
>> define(`number',`esyscmd(`/bin/bash -c "printf \"$RANDOM\""')')dnl
>> number
>> 24246
>> number
>> 4597
>> number
>> 17644

Bah.  Problem of quoting.  "" interpolates within the outer shell, so
you _also_ need to escape the $ to have it make it to the inner shell.

define(`number',`esyscmd(`/bin/bash -c "printf \"\$RANDOM\""')')dnl

That's why I like [] better than `' when mixing m4 with shell, because
'' quoting is easier than "" quoting for writing bash -c 'do-this'
one-liners.

-- 
Eric Blake   [email protected]    +1-801-349-2682
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 619 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBCAAGBQJMbE/AAAoJEKeha0olJ0NqttIIAKW+p4Z8xklDJHkZI1rAWlaN
AT7NK+NhzDKbuzrUUXxrCuYsresGart1x32aMMUITrRHG8p0zJ26kCN0iqKNkyd2
tfNTC4+bQnuZTStJKcDomJF8iA+j/9JVhvpfxhpwiXhsAXEIuvlG7291+vFQcqev
X7MZw28WZrWthIn3k12fiKhwCtdVvFQ7m56iSv7S1y4x4DTBG+/feobgyBmKv6qM
gO6lBK8I1A/ejo2QFW3+smBb3g8N7CsFX0swNyWkf3pr02FQg2aPjn/8BkCM97pD
b59VePgpzwmgtDsBhi3g1ca4/OIakvj25M53SZ9SufVj1PUF9ma5+WNp2W7eZuw=
=aPkb
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.