From 869f2772e1a313ca9271d6c66e8ba504de9f6056 Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Mon, 22 Dec 2025 13:37:26 -0800 Subject: document priority logic --- gbpm.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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))" -- cgit v1.2.3-70-g09d2