From 8a54967788773f07f4ff37bbab7171db6aa4623b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Van=C4=9Bk?= Date: Tue, 24 Mar 2026 12:30:51 +0100 Subject: [PATCH 1/2] fix: quote grep patterns in get_tag to match version delimiter correctly The unquoted \. was likely a typo for a literal dot, but it expands to . (any char), which silently matches the - delimiter after the version. Quote the patterns and use an explicit - to match the actual tag format. --- build.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 6228e60..26224b9 100755 --- a/build.sh +++ b/build.sh @@ -20,11 +20,13 @@ function install_dependencies { # prints the git tag corresponding to the newest and best matching the provided kernel version $1 function get_tag { - local KERNEL_VERSION=$1 + local KERNEL_VERSION="${1}" # list all tags from newest to oldest - (git --no-pager tag -l --sort=-creatordate | grep microvm-kernel-$KERNEL_VERSION\..*\.amzn2 \ - || git --no-pager tag -l --sort=-creatordate | grep kernel-$KERNEL_VERSION\..*\.amzn2) | head -n1 + ( + git --no-pager tag -l --sort=-creatordate | grep "microvm-kernel-${KERNEL_VERSION}-.*\.amzn2" \ + || git --no-pager tag -l --sort=-creatordate | grep "kernel-${KERNEL_VERSION}-.*\.amzn2" + ) | head -n1 } function build_version { From c4b33b5c1d6559f0a7f1ca4b2b0ff8e5b7e64bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Van=C4=9Bk?= Date: Tue, 24 Mar 2026 13:14:04 +0100 Subject: [PATCH 2/2] refactor: use braces instead of subshell in get_tag No need to fork a subshell for the grep fallback; a brace group works the same way and avoids the overhead. --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 26224b9..b7fada4 100755 --- a/build.sh +++ b/build.sh @@ -23,10 +23,10 @@ function get_tag { local KERNEL_VERSION="${1}" # list all tags from newest to oldest - ( + { git --no-pager tag -l --sort=-creatordate | grep "microvm-kernel-${KERNEL_VERSION}-.*\.amzn2" \ || git --no-pager tag -l --sort=-creatordate | grep "kernel-${KERNEL_VERSION}-.*\.amzn2" - ) | head -n1 + } | head -n1 } function build_version {