[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: about the version number of the package
From: |
Ralf Wildenhues |
Subject: |
Re: about the version number of the package |
Date: |
Sun, 1 Nov 2009 12:09:49 +0100 |
User-agent: |
Mutt/1.5.20 (2009-08-09) |
* Vincent Torri wrote on Sun, Nov 01, 2009 at 12:00:13PM CET:
> I wanted to write an m4 macro to be put in a lot of our configure.ac
> files. The problem is that the code contain '$1' to compute the
> parts of the version of the package (major, minor, etc...). The code
> is the following:
>
> VMAJ=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $1);}'`
> VMIN=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $2);}'`
> VMIC=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $3);}'`
> SNAP=`echo $PACKAGE_VERSION | awk -F. '{printf("%s", $4);}'`
> version_info=`expr $VMAJ + $VMIN`":$VMIC:$VMIN"
>
> So, actually, my first question is: is there a better way to compute
> the major, etc.. parts of the version number ?
Better in terms of less forks, but also typically harder to grok for
developers not fluent in shell handling:
save_IFS=$IFS
IFS=.
set x $PACKAGE_VERSION
IFS=$save_IFS
shift
VMAJ=$1 VMIN=$2 VMIC=$3 SNAP=$4
version_info=...
Note that this scribbles over the positional parameters.
> If not, how can I tell m4 to not expand $* in the printf command ?
If you are in a singly-m4-quoted environment: $[]* $[]1 or $[1] or so
If you are in a singly-m4-quoted environment: $][* $][1 ...
Cheers,
Ralf