aboutsummaryrefslogtreecommitdiff
path: root/gbpm.sh
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-22 13:37:26 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2025-12-22 13:37:26 -0800
commit869f2772e1a313ca9271d6c66e8ba504de9f6056 (patch)
treef4bd81de7bd137dce22b4ffd26dc43c5c1b9de64 /gbpm.sh
parent50499dbf5d3c7cd436af2b063efcf08900d2d384 (diff)
downloadgbpm-869f2772e1a313ca9271d6c66e8ba504de9f6056.tar.gz
gbpm-869f2772e1a313ca9271d6c66e8ba504de9f6056.tar.xz
document priority logic
Diffstat (limited to 'gbpm.sh')
-rwxr-xr-xgbpm.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/gbpm.sh b/gbpm.sh
index 9518fba..3d4cc89 100755
--- a/gbpm.sh
+++ b/gbpm.sh
@@ -124,6 +124,20 @@ cmd_set() {
[[ "${bn}" == *"${1}"* ]] || continue
+ # lower depth (i.e. fewer hyphens before match) is preferred,
+ # e.g. `2' matches `python-2.0' over `python-3.0-2'.
+ #
+ # priority at the same depth, using `2.1' as an example:
+ # - from start/hyphen to end (python-2.1)
+ # - from start/hyphen to hyphen (python-2.1-2)
+ # - from start/hyphen to dot (python-2.1.3)
+ # - from start/hyphen (python-2.11)
+ # - other (python-3.2.1)
+ #
+ # at the same priority, the last match (i.e. greatest
+ # version-sorted string) is used, e.g. `3' matches
+ # `python-3.14' over `python-3.2'.
+
prefix="${bn%%${1}*}"
pri="${prefix//[^-]}"
pri="$((${#pri} * 5))"