Skip to content

Commit 17185b4

Browse files
committed
Normalize storage pool locale handling (#562)
1 parent c15a87b commit 17185b4

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

install.sh

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,11 @@ create_lxc_container() {
576576
local idx=1
577577

578578
while IFS= read -r line; do
579-
local storage_name=$(echo "$line" | awk '{print $1}')
580-
local storage_type=$(echo "$line" | awk '{print $2}')
581-
local avail_gb=$(echo "$line" | awk '{print $6/1048576}')
582-
local total_gb=$(echo "$line" | awk '{print $4/1048576}')
583-
local used_pct=$(echo "$line" | awk '{print $7}')
584-
579+
local storage_name storage_type avail_gb total_gb used_pct parsed_line
580+
parsed_line=$(LC_NUMERIC=C awk '{printf "%s,%s,%.1f,%.1f,%s", $1, $2, $6/1048576, $4/1048576, $7}' <<< "$line")
581+
[[ -z "$parsed_line" ]] && continue
582+
IFS=',' read -r storage_name storage_type avail_gb total_gb used_pct <<< "$parsed_line" || continue
583+
585584
storage_names+=("$storage_name")
586585
LC_ALL=C printf " %d) %-15s %-8s %6.1f GB free of %6.1f GB (%s used)\n" \
587586
"$idx" "$storage_name" "$storage_type" "$avail_gb" "$total_gb" "$used_pct"
@@ -716,12 +715,11 @@ create_lxc_container() {
716715
local idx=1
717716

718717
while IFS= read -r line; do
719-
local storage_name=$(echo "$line" | awk '{print $1}')
720-
local storage_type=$(echo "$line" | awk '{print $2}')
721-
local avail_gb=$(echo "$line" | awk '{print $6/1048576}')
722-
local total_gb=$(echo "$line" | awk '{print $4/1048576}')
723-
local used_pct=$(echo "$line" | awk '{print $7}')
724-
718+
local storage_name storage_type avail_gb total_gb used_pct parsed_line
719+
parsed_line=$(LC_NUMERIC=C awk '{printf "%s,%s,%.1f,%.1f,%s", $1, $2, $6/1048576, $4/1048576, $7}' <<< "$line")
720+
[[ -z "$parsed_line" ]] && continue
721+
IFS=',' read -r storage_name storage_type avail_gb total_gb used_pct <<< "$parsed_line" || continue
722+
725723
storage_names+=("$storage_name")
726724
LC_ALL=C printf " %d) %-15s %-8s %6.1f GB free of %6.1f GB (%s used)\n" \
727725
"$idx" "$storage_name" "$storage_type" "$avail_gb" "$total_gb" "$used_pct"

0 commit comments

Comments
 (0)