Skip to content

Commit d83c4be

Browse files
authored
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
1 parent f930117 commit d83c4be

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎41_snapshots-btrfs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fi
134134

135135
# Root subvolume UUID
136136
root_uuid_subvolume="$(btrfs subvolume show / 2>/dev/null | \
137-
awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"
137+
awk -F':' '/^[ \t]*UUID/ {gsub(/^[ \t]+/, "", $2); print $2}')"
138138
[ -z "$root_uuid_subvolume" ] && print_error "UUID of the root subvolume is not available"
139139

140140
# ---------- Boot partition ----------
@@ -150,7 +150,7 @@ fi
150150
# If /boot is not a Btrfs subvolume, reuse root subvol UUID
151151
boot_uuid_subvolume="$(
152152
btrfs subvolume show "${boot_directory}" 2>/dev/null | \
153-
awk -F':' '/^\s*UUID/ {gsub(/^[ \t]+/, "", $2); print $2; exit}'
153+
awk -F':' '/^[ \t]*UUID/ {gsub(/^[ \t]+/, "", $2); print $2; exit}'
154154
)"
155155
[ -z "$boot_uuid_subvolume" ] && boot_uuid_subvolume="$root_uuid_subvolume"
156156

0 commit comments

Comments
 (0)