Merge pull request 'vars: fix case if we have two vars with where one is the prefix of another one' (#2390) from var-fix-get into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/2390
This commit is contained in:
Mic92
2024-11-12 16:11:39 +00:00

View File

@@ -17,7 +17,11 @@ def get_var(machine: Machine, var_id: str) -> Var:
vars_ = get_vars(machine)
results = []
for var in vars_:
if var_id in var.id:
if var.id == var_id:
# exact match
results = [var]
break
if var.id.startswith(var_id):
results.append(var)
if len(results) == 0:
msg = f"No var found for search string: {var_id}"