ComplianceAsCode/content

View on GitHub
utils/version.sh

Summary

Maintainability
Test Coverage
#!/bin/bash
 
Double quote to prevent globbing and word splitting.
Quote this to prevent word splitting.
content_cmakelists="$(realpath $(dirname ${BASH_SOURCE[0]}))/../CMakeLists.txt"
major_version=$(grep "set(SSG_MAJOR_VERSION" "$content_cmakelists" | sed "s/.*SSG_MAJOR_VERSION \([[:digit:]]*\).*/\1/")
minor_version=$(grep "set(SSG_MINOR_VERSION" "$content_cmakelists" | sed "s/.*SSG_MINOR_VERSION \([[:digit:]]*\).*/\1/")
patch_version=$(grep "set(SSG_PATCH_VERSION" "$content_cmakelists" | sed "s/.*SSG_PATCH_VERSION \([[:digit:]]*\).*/\1/")
 
echo "$major_version.$minor_version.$patch_version"