Skip to content

Fix portable awk UUID whitespace matching - #433

Closed
Puddingstomp wants to merge 1 commit into
Antynea:masterfrom
Puddingstomp:patch-1
Closed

Puddingstomp wants to merge 1 commit into
Antynea:masterfrom
Puddingstomp:patch-1

Conversation

@Puddingstomp

Copy link
Copy Markdown

Possibly related to #220

On Kubuntu 25.10, grub-btrfs failed during grub-mkconfig with:

UUID of the root subvolume is not available

The root subvolume did have a UUID, but awk did not match it because \s is not portable in awk regular expressions. Replacing \s with POSIX [[:space:]] fixed detection and allowed snapshot entries to generate correctly.

Tested on Kubuntu 25.10 with Btrfs root subvolume @ and Snapper snapshots under @/.snapshots.

On Kubuntu 25.10, grub-btrfs failed during grub-mkconfig with:

UUID of the root subvolume is not available

The root subvolume did have a UUID, but awk did not match it because \s is not portable in awk regular expressions. Replacing \s with POSIX [[:space:]] fixed detection and allowed snapshot entries to generate correctly.

Tested on Kubuntu 25.10 with Btrfs root subvolume @ and Snapper snapshots under @/.snapshots.
@Antynea

Antynea commented May 29, 2026

Copy link
Copy Markdown
Owner

Thanks for the report and for digging into the issue on Kubuntu 25.10 — the root cause you identified is real.

That said, I want to clarify the design context: grub-btrfs explicitly declares gawk as a dependency, and the script is intentionally not POSIX-portable — it relies on bash, grep -P (GNU Perl-compatible regex), and other GNU-specific constructs throughout. Replacing \s with [[:space:]] in these two awk patterns while the rest of the script continues to use GNU-only features would be an inconsistent and partial fix.

Your report does however highlight something worth addressing on our side: the script should probably invoke gawk explicitly rather than awk, which would make the declared dependency actually effective and prevent this class of issues entirely. I'd rather fix it at that level than patch individual patterns.

I'm leaving this open for now — happy to continue the discussion.

@Antynea

Antynea commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Coming back to this after taking a proper look. My previous comment was wrong on the facts, and I'd rather say so plainly than quietly merge something that contradicts it.

Two corrections:

The script is not GNU-by-design where awk is concerned. These two \s patterns are the only gawk-specific awk constructs in the entire file. Every other awk expression in it already runs correctly under mawk, and the Timeshift parsing already uses [ \t] for exactly this purpose. So this isn't a partial POSIX fix applied to a GNU script; it removes the last gawk-only construct and makes the file consistent with itself.

Invoking gawk explicitly, which I said I'd prefer, would have made things worse for the people actually hitting this. gawk is not installed by default on Debian or Ubuntu; mawk is. Those users would have gone from an empty UUID to gawk: command not found. The declared dependency doesn't protect them either: nothing in the script checks for gawk, unlike btrfs-progs which is checked explicitly, so this fails silently instead of loudly.

For context: I develop on Arch, where awk is gawk. This whole class of bug is invisible from there, which is why I misjudged it, and why reports like yours matter. You were right in May and I should have acted on it then; sorry for the delay.

On which patch to take: I'm going with #441, which does the same thing with [ \t] rather than [[:space:]]. Both are correct; I tested both against gawk, mawk, the One True Awk and busybox awk. The only tiebreaker is that [ \t] is already the notation used elsewhere in the file, including on the gsub of the very same line. That's a thin margin, and it takes nothing away from your diagnosis, which was right from the start.

Closing this one in favour of #441.

@Antynea Antynea closed this Aug 24, 2026
Antynea added a commit that referenced this pull request Aug 24, 2026
Since #441 the script no longer uses any gawk-specific awk construct.
All of its awk expressions were checked against gawk, mawk, the One True
Awk and busybox awk, and run unmodified on all four.

Declaring gawk advertised a requirement that the script never enforced
and that most users could not satisfy anyway, since mawk is the default
awk on Debian, Ubuntu and derivatives.

Refs #433, #441
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.

2 participants