summaryrefslogtreecommitdiffstats
path: root/get-version.sh
blob: f962146264982e1e39d974671c23e7f627715333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh

# Needed to remove the new line when echoing the version
nl='
'

VERSION=

usage="\
Usage: $0 version_file
Print a version string.
"

version_file="$1"
if test -z "$version_file"; then
  echo "$usage"
  exit 1
fi
if test -f $version_file; then
  . ./$version_file
else
  echo "Version file $version_file not found"
  exit 1
fi

if test -z $PKG_VERSION; then
  echo "No version found in $version_file"
  exit 1
fi

# Omit the trailing newline
echo "$PKG_VERSION" | tr -d "$nl"