File: parse_version.sh

package info (click to toggle)
dlt-viewer 2.23.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,432 kB
  • sloc: cpp: 27,832; ansic: 4,454; xml: 491; sh: 154; makefile: 75
file content (19 lines) | stat: -rwxr-xr-x 516 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
set -eu

_print_usage() {
    echo "Parse DLT Viewer version.h and return version number depending on requested part."
    echo "Usage: parse_version.sh <path to version.h> <PACKAGE_MAJOR_VERSION | PACKAGE_MINOR_VERSION | PACKAGE_PATCH_LEVEL>"
}

if [[ $# -ne 2 ]]; then
    _print_usage
    exit 1
fi

if [ "${2}" != "PACKAGE_MAJOR_VERSION" -a "${2}" != "PACKAGE_MINOR_VERSION" -a "${2}" != "PACKAGE_PATCH_LEVEL" ]; then
    _print_usage
    exit 1
fi

echo $(grep ${2} ${1} | awk '{print $3}')