mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-25 17:55:21 +00:00
klipper-flash: fix getConfigField across multi-line configs
#533030 changed `getConfigField`'s regex to stop it matching commented-out lines, but in doing so broke checking across multiple lines. `builtins.match` requires the whole string to match, and `[^#\r\n]*` can never cross a newline, so the field can only be found if it sits on line 1 of the file. Fix by regexing each line independently. Assisted-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -17,9 +17,11 @@ let
|
||||
field:
|
||||
with builtins;
|
||||
let
|
||||
matches = match ''^[^#\r\n]*${field}="([a-zA-Z0-9_]+)".*$'' (readFile firmwareConfig);
|
||||
lines = lib.splitString "\n" (readFile firmwareConfig);
|
||||
matchLine = line: match ''${field}="([a-zA-Z0-9_]+)".*'' line;
|
||||
matched = lib.findFirst (line: matchLine line != null) null lines;
|
||||
in
|
||||
if matches != null then head matches else null;
|
||||
if matched != null then head (matchLine matched) else null;
|
||||
matchPlatform = getConfigField "CONFIG_BOARD_DIRECTORY";
|
||||
matchBoard = getConfigField "CONFIG_MCU";
|
||||
matchAvrdudeProtocol = getConfigField "CONFIG_AVRDUDE_PROTOCOL";
|
||||
|
||||
Reference in New Issue
Block a user