<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>I'd like to (finally) move the default versions out into a simple file.<br><br>Given:<br><br>jbook15:/dev2/cm3/scripts jay$ cat version <br>CM3VERSION d5.7.0<br>CM3VERSIONNUM 050700<br>CM3LASTCHANGED 2008-03-16<br><br>Is there any chance this is Posix/Solaris compliant?<br><br>get_version() {<br> if [ -n "$(eval echo \$$1)" ] ; then<br> return<br> fi<br> eval "$1=\"$(echo $(grep "$1 " $root/scripts/version | awk '{print $2}'))\""<br>}<br><br>get_version CM3VERSION<br>get_version CM3VERSIONNUM<br>get_version CM3LASTCHANGED<br>echo "CM3VERSION is $CM3VERSION"<br>echo "CM3VERSIONNUM is $CM3VERSIONNUM"<br>echo "CM3LASTCHANGED is $CM3LASTCHANGED"<br><br>It works on my Mac.<br>This is not what I would have expected, in particular the need<br>for eval and echo seems strange.<br>The quoting is all unfortunate as usual too.<br><br>If this isn't standard, then how about just the last line:<br>get_version() {<br> eval "$1=\"$(echo $(grep "$1 " $root/scripts/version | awk '{print $2}'))\""<br>
}<br>
?<br><br>Otherwise, I guess dumb it down and be repetitive, like:<br>CM3VERSION=${CM3VERSION-`grep "CM3VERSION " $root/scripts/version | awk '{print $2}'))`}<br>
<br>? I didn't want to repeat the variable names three times each.<br><br>What I really want is to append version to PKGS and regenerate PKGS whenever its lines aren't all there,<br>so as to trigger an automatic rebuild of PKGS when the version changes.<br>One more application of the version numbers, and I was pushed to fix them.<br><br>Full diff:<br><br>Index: sysinfo.sh<br>===================================================================<br>RCS file: /usr/cvs/cm3/scripts/sysinfo.sh,v<br>retrieving revision 1.61<br>diff -c -r1.61 sysinfo.sh<br>*** sysinfo.sh 15 Apr 2008 06:51:31 -0000 1.61<br>--- sysinfo.sh 20 Apr 2008 03:48:13 -0000<br>***************<br>*** 10,38 ****<br> <br> PRJ_ROOT=${PRJ_ROOT:-${HOME}/work}<br> <br>- #-----------------------------------------------------------------------------<br>- # set some defaults<br> #<br>! # These three lines must be carefully formed as they are parsed by other code.<br> #<br>! # For cmd:<br>! # They must start with a name and an equals sign.<br>! # They must contain one and only one colon.<br>! # They must contain one and only one equals sign.<br>! # The content to the right of the colon, minus the first two<br>! # and last two characters, is the value.<br> #<br>! # For Python, we have much more flexibility. Currently the code<br>! # looks for fairly precisely A=${A:-"value"}, but this can be easily<br>! # relaxed or changed.<br> #<br>! # Refer to scripts/win/sysinfo.cmd and scripts/python/lib.py.<br>! # Specifically look for "DefaultsFromSh".<br> #<br> CM3VERSION=${CM3VERSION:-"d5.7.0"}<br> CM3VERSIONNUM=${CM3VERSIONNUM:-"050700"}<br> CM3LASTCHANGED=${CM3LASTCHANGED:-"2008-03-16"}<br> <br> CM3_GCC_BACKEND=yes<br> CM3_GDB=no<br> #<br>--- 10,49 ----<br> <br> PRJ_ROOT=${PRJ_ROOT:-${HOME}/work}<br> <br> #<br>! # Allow direct invocation of sysinfo.sh for testing purposes.<br> #<br>! if [ -z "$root" -o ! -d "$root" ] ; then<br>! root=`pwd`<br>! while [ -n "$root" -a ! -f "$root/scripts/sysinfo.sh" ] ; do<br>! root=`dirname $root`<br>! done<br>! fi<br>! <br>! #-----------------------------------------------------------------------------<br>! # set some defaults<br> #<br>! <br>! get_version() {<br>! if [ -n "$(eval echo \$$1)" ] ; then<br>! return<br>! fi<br>! eval "$1=\"$(echo $(grep "$1 " $root/scripts/version | awk '{print $2}'))\""<br>! }<br>! <br>! get_version CM3VERSION<br>! get_version CM3VERSIONNUM<br>! get_version CM3LASTCHANGED<br>! <br> #<br>! # Leave these lines in TEMPORARILY for compat with cmd, Python, Quake.<br> #<br> CM3VERSION=${CM3VERSION:-"d5.7.0"}<br> CM3VERSIONNUM=${CM3VERSIONNUM:-"050700"}<br> CM3LASTCHANGED=${CM3LASTCHANGED:-"2008-03-16"}<br> <br>+ CM3_INSTALL=${CM3_INSTALL:-`dirname \`find_exe cm3 /usr/local/cm3/\ \``}<br>+ <br> CM3_GCC_BACKEND=yes<br> CM3_GDB=no<br> #<br><br> - Jay</body>
</html>