Created
August 8, 2020 20:47
-
-
Save sgen/8f6d39d1641d797c8e2ac79020625e03 to your computer and use it in GitHub Desktop.
Bash Semantic Versioning Validation Regular Expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
version="$1" | |
[[ -z "$version" ]] && { echo "no version provided" >&2; exit 1; } | |
semver_regexp='^[vV]?(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(\-([0-9A-Za-z]*)(\.([0-9A-Za-z]*))*)?(\+[0-9A-Za-z-]+(\.[0-9A-Za-z-])*)?$' | |
[[ ! "$version" =~ $semver_regexp ]] && { echo "$version is not valid" >&2; exit 1; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment