cli-flash: match image selectors as full fields, not substrings

The per-selector image filter used a loose substring test
(candidate == *"${token}"*). Image names are
VENDOR_VERSION_Board_release_branch_kver..., where Board/release/branch are
underscore-delimited middle fields, so a short release/branch (e.g. 'sid',
'edge') could match inside another field and keep the wrong image. Anchor each
selector to a complete _-delimited field (*"_${token}_"*). Empty selectors are
still skipped and the sequential board->release->branch narrowing is unchanged.

Signed-off-by: Igor Pecovnik <igor@armbian.com>
This commit is contained in:
Igor Pecovnik
2026-08-30 19:00:59 +02:00
committed by Igor
parent 904cab7b5f
commit bbe2dcc894
+6 -1
View File
@@ -68,7 +68,12 @@ function cli_flash() {
fi
declare -a kept=()
for candidate in "${images[@]}"; do
if [[ "${candidate##*/}" == *"${token}"* ]]; then
# Match the selector as a complete underscore-delimited field, not
# a loose substring: image names are
# VENDOR_VERSION_Board_release_branch_kver..., where Board/release/
# branch are all middle fields, so a short release/branch (e.g.
# 'sid', 'edge') can't accidentally match inside another field.
if [[ "${candidate##*/}" == *"_${token}_"* ]]; then
kept+=("${candidate}")
fi
done