Skip to content

Conversation

@pmenzel
Copy link
Contributor

@pmenzel pmenzel commented Sep 18, 2026

No description provided.

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 <noreply@anthropic.com>
Fixes: 74d8a45 ("Add hostconfig")
@pmenzel pmenzel merged commit 5f15a05 into master Sep 18, 2026
@@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not /^[a-z][a-z0-9\$_-]*$/i if intention "to allow letters, digits, underscore and dash in tag names" is assumed? NIT, just wondering....

Sign in to join this conversation on GitHub.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants