Go to file
yafox 6474b0ba3a
initial commit
2020-11-24 21:28:40 +00:00
.gitignore initial commit 2020-11-24 21:28:40 +00:00
LICENSE initial commit 2020-11-24 21:28:40 +00:00
README initial commit 2020-11-24 21:28:40 +00:00
makefile initial commit 2020-11-24 21:28:40 +00:00
sloc.sh initial commit 2020-11-24 21:28:40 +00:00
vercmp.sh initial commit 2020-11-24 21:28:40 +00:00



51 SLOC, not counting format scripts.

vercmp evaluates a version comparison expression and prints "yes" if the
expression evaluates to true and "no" otherwise.

vercmp can be extended with additional formats by adding a shell script defining
a `comparever` function to the `format` subdirectory.  no `format` subdirectory
is included by default.  to make bootstrapping easier, instructions for pulling
some are included in the makefile.  if bootstrapping lix os, for example, the
following will `git clone` lix os' vercmp formats into the format directory:

    make lix-os-formats

or, if wanting a basis for creating one's own formats using the same foundatiion
as lix os' formats:

    make bare-formats

to install, just `make install`.


    vercmp <comparison string> [format]
    vercmp formats

comparison string:
    "<version 1> <op> <version 2>"

    == equal
    >= greater than or equal
    <= less than or equal
    >  greater than
    <  less than

    the name of the format to use for parsing and comparing the versions.
	see 'vercmp formats' for a list of formats.
	(format scripts are kept in $VERCMPROOT/format)

## examples

    $ vercmp "1.2.3 >= 3.2.1"

    $ vercmp "1.2 == 1.2"                                                                           

    $ vercmp "1.2+meta1 == 1.2+meta2"                                                               

    $ vercmp "1.2+meta1 > 1.2-rc1+meta2"                                                            

    $ vercmp "1.2-rc1 < 1.2-rc2"

## caveat

vercmp format scripts assume both versions are in the same format.  if this is
not the case, undefined behavior may ensue.  even a simple variation like the
following can have unexpected results:

     $ vercmp "1.2 == 1.2.0"