Skip to content

A POSIX shell SemVer function to extract Semantic Version fragments.

License

Notifications You must be signed in to change notification settings

peppergrayxyz/posix-shell-semver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

POSIX shell SemVer

A posix shell function that captures the fragments of the Semantic Versioning Specification. This repo also contains a short script that runs the function against a set of example version numbers to check its validity.

This uses only built-in POSIX shell commands. Think of it as an extension to the suggested regex FAQ entry for use in sh and other posix compliant shells.

Usage

#!/usr/bin/env sh

. "./semver.sh"

if semver "$1"; then
    echo "Major: $major";
    echo "Minor: $minor";
    echo "Patch: $patch";
    [ -n "$prerelease" ] && echo "Pre-release: $prerelease"
    [ -n "$buildmetadata" ] && echo "Build Metadata: $buildmetadata"
else 
    echo "No match found!";
fi 

Original Source

This repo came to life following a discussion in an issue in the semver repo on GitHub. See here. Forked from here which implements a version for bash.

About

A POSIX shell SemVer function to extract Semantic Version fragments.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%