[PATCH v3 07/14] scripts: Use shell expansion to get partition path

Demi Marie Obenour
2025-11-19T08:21:33Z

Avoids a pointless call to awk. No functional change intended.

Signed-off-by: Demi Marie Obenour <demiobenour@gmail.com>
---
Changes since v2:

- Move into separate commit.
---
scripts/make-gpt.sh | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh
index 91c6038f67d4d4906fec4a3412f2ff5fca2671d5..ebb19c32a0d3bc3f86bf4748460971888d73e1fc 100644
--- a/scripts/make-gpt.sh
+++ b/scripts/make-gpt.sh
@@ -28,13 +28,6 @@ fillPartition() {
lseek -S 1 "$start" cat "$3" 1<>"$1"
}

-# Prints the partition path from a PATH:PARTTYPE[:PARTUUID[:PARTLABEL]] string.
-partitionPath() {
- awk -F: '{print $1}' <<EOF
-$1
-EOF
-}
-
scriptsDir="$(dirname "$0")"

out="$1"
@@ -49,8 +42,7 @@ for partition; do
sizeMiB=${BASH_REMATCH[1]}
partition=${partition%:*}
else
- partitionPath=$(partitionPath "$partition")
- sizeMiB=$(sizeMiB "$partitionPath")
+ sizeMiB=$(sizeMiB "${partition%%:*}")
fi
table+=$'\n'"size=${sizeMiB}MiB,$(awk -f "$scriptsDir/sfdisk-field.awk" -v partition="$partition")"
gptBytes=$((gptBytes + sizeMiB * ONE_MiB))
@@ -64,7 +56,6 @@ EOF

n=0
for partition; do
- partitionPath=$(partitionPath "$partition")
- fillPartition "$out" "$n" "$partitionPath"
+ fillPartition "$out" "$n" "${partition%%:*}"
n=$((n + 1))
done

--
2.52.0