#! /bin/sh set -eu patest() { pkg=$1 expected=$2 pattern=$3 if pkg_admin pmatch "$pattern" "$pkg"; then actual="matches" else actual="nomatch" fi if [ "$actual" = "$expected" ]; then result="ok" else result="FAIL" fi printf '%s\t%s %s %s\n' $result "$pkg" "$expected" "$pattern" } patest "foo-1.0" matches "foo>=0" patest "foo-1.0" matches "foo-1.0" patest "foo-1.0" matches "foo>=1" patest "foo-1.0" matches "foo>=1.0.0.0" patest "foo-1.0" nomatch "foo>1" patest "foo-1.0" matches "foo-*" patest "foo-client-1.0" matches "foo-*" patest "foo-1.0" matches "foo-[0-9]*" patest "foo-1.0nb1" matches "foo-1.*" patest "foo-1.0nb1" matches "foo>=1.0" patest "foo-1.0nb2" matches "foo>1.0" patest "foo-1.0nb2" matches "foo>1nb1" patest "foo-1.0nb2" nomatch "foo>1nb2" patest "foo-1.0nb2" matches "foo<1nb3" patest "foo-10.3" matches "foo-1*" patest "foo-10.3nb7" matches "foo-1*"