-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Pádraig Brady on 10/21/2008 4:04 PM: > echo "$ver" | sed ' > s/^\([0-9]\{,\}\)\.\([0-9]\{,\}\)[.0]*$/\1.\2.0/; #1.10 -> > 1.10.0 > s/^\([0-9]\{,\}\)\.\([0-9]\{,\}\)\([a-z]\)/\1.\2.99\3/; #1.10a -> > 1.10.99a
For what it's worth, Autoconf does this by converting \([0-9]+\)\([a-z]+\) to \1+1, -1, radix36(\2). In other words, 1.10a becomes 1.11.-1.10. - From there, it is a simple numerical comparison, supplying a 0 for any implicit field, and declaring results at the left-most field that differs: 1.10.x < 1.11.-1.x, but 1.11.-1 < 1.11.0 Hmm. Since bootstrap requires the existence of autoconf, why not just use autoconf, instead of reimplementing this in sed? echo 'm4_divert(0)m4_version_compare('$ver,$prereq')' \ | autom4te --language=m4sugar - outputs -1 if $ver is smaller, 0 if equal, 1 if greater than $prereq. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkj+eysACgkQ84KuGfSFAYDRIgCfac1TIX15RSd3k2x7m9Run/VZ OZUAniSlTlfS0PsVNXO5iH8DZaw5FGMY =4hbV -----END PGP SIGNATURE----- _______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils