Linux doesn't play nice with fputs return values, found the hard way by Ryan Mullen...
[xombrero.git] / version.sh
blob2440cdada404fb03340f6f5cfb5123f61dc35fe2
1 #!/bin/sh
3 # Get version from header.
5 HEADER=version.h
6 SCRIPT=version.sh
7 if [ ! -f "$HEADER" ]; then
8 echo "$SCRIPT: error: $HEADER does not exist" 1>&2
9 exit 1
11 PAT_PREFIX='^#define[[:space:]]+XXXTERM_'
12 PAT_SUFFIX='[[:space:]]+[0-9]+$'
13 MAJOR=$(egrep "${PAT_PREFIX}MAJOR${PAT_SUFFIX}" $HEADER | awk '{print $3}')
14 MINOR=$(egrep "${PAT_PREFIX}MINOR${PAT_SUFFIX}" $HEADER | awk '{print $3}')
15 PATCH=$(egrep "${PAT_PREFIX}PATCH${PAT_SUFFIX}" $HEADER | awk '{print $3}')
16 if [ -z "$MAJOR" -o -z "$MINOR" -o -z "$PATCH" ]; then
17 echo "$SCRIPT: error: unable to get version from $HEADER" 1>&2
18 exit 1
20 echo $MAJOR.$MINOR.$PATCH | tr -d '\n'