mirror of
https://github.com/Antynea/grub-btrfs.git
synced 2026-10-20 02:42:03 +08:00
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:
+2
-2
@@ -134,7 +134,7 @@ fi
|
|||||||
|
|
||||||
# Root subvolume UUID
|
# Root subvolume UUID
|
||||||
root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
|
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"
|
[ -z "$root_uuid_subvolume" ] && print_error "UUID of the root subvolume is not available"
|
||||||
|
|
||||||
# ---------- Boot partition ----------
|
# ---------- Boot partition ----------
|
||||||
@@ -150,7 +150,7 @@ fi
|
|||||||
# If /boot is not a Btrfs subvolume, reuse root subvol UUID
|
# If /boot is not a Btrfs subvolume, reuse root subvol UUID
|
||||||
boot_uuid_subvolume="$(
|
boot_uuid_subvolume="$(
|
||||||
btrfs subvolume show "${boot_directory}" 2>/dev/null | \
|
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"
|
[ -z "$boot_uuid_subvolume" ] && boot_uuid_subvolume="$root_uuid_subvolume"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user