From 8699b3ce773425f5b51dcfb8a9b910cc7d29b8a1 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 18 Sep 2026 10:41:27 +0200 Subject: [PATCH] hostconfig: Do not interpolate $_ into the term-validation regex The character class in the term check is written as [a-z0-9$_-], intending to allow letters, digits, underscore and dash in tag names. Perl interpolates $_ (the token currently being examined) into the class, though. As a result the accepted characters depend on the token itself, and any term containing a dash aborts the whole evaluation: $ hostconfig 'nvidia-no-gsp' Invalid [] range "t-d" in regex; marked by <-- HERE in m/^[a-z][a-z0-9nvidia-no-gsp <-- HERE -]*$/ at /usr/sbin/hostconfig line 43. Drop the stray $ so the class is literal and dashed tag names work. Assisted-by: Claude Fable 5 Fixes: 74d8a4557fa0 ("Add hostconfig") --- hostconfig/hostconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hostconfig/hostconfig b/hostconfig/hostconfig index 8d98aade..91cd6961 100755 --- a/hostconfig/hostconfig +++ b/hostconfig/hostconfig @@ -40,7 +40,7 @@ sub evalue_expression { $options{'debug'} and warn join(' ',map("'$_'",@l)),"\n"; for (@l) { s/\s*(.+?)\s*/$1/; - if (/^[a-z][a-z0-9$_-]*$/i) { + if (/^[a-z][a-z0-9_-]*$/i) { $_=exists $tags->{$_} ? 1 : 0; } }