fix: use portable whitespace matching in awk UUID parsing (#441)

The awk expressions parsing `btrfs subvolume show` used `\s`, a GNU
extension. mawk and the One True Awk treat it as a literal `s`, so
`/^\s*UUID/` never matches a tab-indented line and the UUID comes back
empty. Since `awk` is mawk by default on Debian, Ubuntu and derivatives,
grub-mkconfig aborted there with "UUID of the root subvolume is not
available".

Replace `\s` with `[ \t]`, which every awk implementation supports and
which matches the notation already used by the gsub on the same line.

Closes #425
This commit is contained in:
Reynegton Pinheiro Nunes
2026-08-24 14:46:18 +02:00
committed by GitHub
parent f930117cdb
commit d83c4be5ed
+2 -2
View File
@@ -134,7 +134,7 @@ fi
# Root subvolume UUID
root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"
awk -F':' '/^[ \t]*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"
[ -z "$root_uuid_subvolume" ] && print_error "UUID of the root subvolume is not available"
# ---------- Boot partition ----------
@@ -150,7 +150,7 @@ fi
# If /boot is not a Btrfs subvolume, reuse root subvol UUID
boot_uuid_subvolume="$(
btrfs subvolume show "${boot_directory}" 2>/dev/null | \
awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2; exit}'
awk -F':' '/^[ \t]*UUID/ {gsub(/^[ \t]+/, "", $2); print $2; exit}'
)"
[ -z "$boot_uuid_subvolume" ] && boot_uuid_subvolume="$root_uuid_subvolume"