Skip to content

engineering: [osmodifier follow-up] track submenu blocks and brace depth in find_non_recovery_linux_lines#661

Merged
bfjelds merged 1 commit into
user/bfjelds/mjolnir/consolidate-grub-parserfrom
user/bfjelds/mjolnir/submenu-fix
May 27, 2026
Merged

engineering: [osmodifier follow-up] track submenu blocks and brace depth in find_non_recovery_linux_lines#661
bfjelds merged 1 commit into
user/bfjelds/mjolnir/consolidate-grub-parserfrom
user/bfjelds/mjolnir/submenu-fix

Conversation

@bfjelds
Copy link
Copy Markdown
Member

@bfjelds bfjelds commented May 26, 2026

🔍 Description

** This is a change in behavior from Go osmodifier behavior **

Follow up to:

  1. engineering: Port osmodifier from Go binary to native Rust crate #638
  2. engineering: [osmodifier follow-up] add submenu/brace-depth tracking to grub.cfg menuentry parser #656

On systems with multiple kernels installed, grub2-mkconfig produces a top-level menuentry plus a submenu 'Advanced options for ...' containing additional menuentries. The previous parser did not track brace depth or submenu blocks, causing it to find >1 non-recovery linux lines and bail with 'expected 1, found N'.

This commit adds brace-depth tracking (with quote-awareness) and skips submenu { ... } blocks entirely, so only top-level menuentries contribute linux lines. This goes beyond the Go implementation which has the same limitation.

New tests cover: single-kernel with submenu, multi-kernel with submenu, submenu-before-entry ordering, submenu-only (error case), and braces inside quoted titles.

@bfjelds bfjelds force-pushed the user/bfjelds/mjolnir/consolidate-grub-parser branch from 7b69106 to 0355ba3 Compare May 26, 2026 18:22
…_lines

On systems with multiple kernels installed, grub2-mkconfig produces a
top-level menuentry plus a submenu 'Advanced options for ...' containing
additional menuentries. The previous parser did not track brace depth or
submenu blocks, causing it to find >1 non-recovery linux lines and bail
with 'expected 1, found N'.

This commit adds brace-depth tracking (with quote-awareness) and skips
submenu { ... } blocks entirely, so only top-level menuentries contribute
linux lines. This goes beyond the Go implementation which has the same
limitation.

New tests cover: single-kernel with submenu, multi-kernel with submenu,
submenu-before-entry ordering, submenu-only (error case), and braces
inside quoted titles.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bfjelds bfjelds force-pushed the user/bfjelds/mjolnir/submenu-fix branch from eb548c7 to 88cc8b3 Compare May 26, 2026 18:23
@bfjelds bfjelds marked this pull request as ready for review May 27, 2026 00:37
@bfjelds bfjelds requested a review from a team as a code owner May 27, 2026 00:37
@bfjelds bfjelds merged commit 026dd6f into user/bfjelds/mjolnir/consolidate-grub-parser May 27, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant