From bd9fa2933e4f0c65e570f8a9aa17f5e1efd18650 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Sat, 1 Apr 2023 12:34:35 +0200 Subject: [PATCH] Refactor `chooseDisk` function --- scripts/OS/Arch/partition.sh | 2 +- scripts/Scripts/choose-disk.sh | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/OS/Arch/partition.sh b/scripts/OS/Arch/partition.sh index 3098c251..c12b9017 100755 --- a/scripts/OS/Arch/partition.sh +++ b/scripts/OS/Arch/partition.sh @@ -1,7 +1,7 @@ pushd "${BASH_SOURCE%/*}" > /dev/null; source "../../Scripts/choose-disk.sh"; -chooseDisk archDisk "Which disk do you whish to format for installing Arch?"; +archDisk="$(chooseDisk "Which disk do you whish to format for installing Arch?")"; memory="$(cat /proc/meminfo | awk -F " " '/^MemTotal/ { print $2 }')"; swapSize="$(echo "$memory" | awk '{ print int(($1 / 1024 / 1024 4) + 0.5)}')"; diff --git a/scripts/Scripts/choose-disk.sh b/scripts/Scripts/choose-disk.sh index c1e8a8d4..83b4566b 100755 --- a/scripts/Scripts/choose-disk.sh +++ b/scripts/Scripts/choose-disk.sh @@ -1,7 +1,6 @@ #!/bin/bash function chooseDisk() { - local -n result="$1"; - local message="$2"; + local message="$1"; local choice; local disk; local -a disks; @@ -47,7 +46,7 @@ function chooseDisk() { if [ "$choice" -ge 1 ] && [ "$choice" -le "$diskCount" ] then disk=(${disks[$choice]}); - result="/dev/${disk[0]}"; + echo "/dev/${disk[0]}"; return; else >&2 echo "The specified choice \"$choice\" is invalid!";