From 1e6f9fd66f12e547b13975a48c233a12260526e5 Mon Sep 17 00:00:00 2001 From: vasilito Date: Thu, 2 Jul 2026 01:18:22 +0300 Subject: [PATCH] fix: use --set N:VAR regexp idiom in hiperiso_boot for portability The earlier hiperiso_boot function used: if regexp '.*/([^/]+)' "$iso_path" ; then set hiso_base="$1" fi This relies on GRUB's positional $1..$9 capture groups being visible inside the if-branch. While it parses, the modsrc's own grub.cfg uses the explicit --set N:VAR form everywhere (e.g. the FuryBSD/FreeNAS/TrueNAS regexp blocks); switching to that idiom keeps hiperiso_boot consistent with the rest of the file and avoids a class of bugs that would only surface on certain GRUB versions where positional captures interact differently with control flow. --- src/grub2/grub/grub.cfg | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/grub2/grub/grub.cfg b/src/grub2/grub/grub.cfg index 2c74650..bc39ede 100644 --- a/src/grub2/grub/grub.cfg +++ b/src/grub2/grub/grub.cfg @@ -2534,12 +2534,13 @@ function hiperiso_boot { fi # Derive log_dir from ISO basename. GRUB script has no ${var##*/} - # bash pattern; replicate it with regexp: match ".*/" greedily then - # the final segment. If iso_path has no '/', hiso_base stays as the - # whole path (acceptable fallback). + # bash pattern; replicate it with regexp. Use --set N:VAR syntax + # (the same form the Ventoy modsrc uses elsewhere in this file) so + # the captured group is bound to a named variable in the same scope + # rather than to the positional $1 in the if-statement branch. set hiso_base="$iso_path" - if regexp '.*/([^/]+)' "$iso_path" ; then - set hiso_base="$1" + if regexp --set 1:hiso_tail '.*/([^/]+)$' "$iso_path" ; then + set hiso_base="$hiso_tail" fi set hiso_log_dir="/hiperiso/logs/${hiso_base}/"