summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2010-12-12 20:33:15 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2010-12-12 20:34:04 +0100
commitd487df8c9ecf58af3ab46e7f2b898a9b4f6ba097 (patch)
tree3d6cee09d663fd4350d84bd05a8d57d8b4197e81
parent33d5d154c66850c118f1074f215f212fa89ee791 (diff)
make BLOCKFRIENDLY prettier
use arrays, so we can allow whitespace in the labels
-rw-r--r--src/core/libs/lib-ui-interactive.sh12
-rw-r--r--src/core/libs/lib-ui.sh10
2 files changed, 11 insertions, 11 deletions
diff --git a/src/core/libs/lib-ui-interactive.sh b/src/core/libs/lib-ui-interactive.sh
index 5b622d0..1b5be6e 100644
--- a/src/core/libs/lib-ui-interactive.sh
+++ b/src/core/libs/lib-ui-interactive.sh
@@ -246,15 +246,15 @@ interactive_prepare_disks ()
interactive_autoprepare()
{
listblockfriendly
- if [ $(echo $BLOCKFRIENDLY | wc -w) -gt 1 ]
+ if [ ${#BLOCKFRIENDLY[@]} -gt 2 ]
then
- ask_option no 'Harddrive selection' "Select the hard drive to use" required $BLOCKFRIENDLY || return 1
+ ask_option no 'Harddrive selection' "Select the hard drive to use" required "${BLOCKFRIENDLY[@]}" || return 1
DISC=$ANSWER_OPTION
- elif [ -z "$BLOCKFRIENDLY" ]; then
+ elif [ ${#BLOCKFRIENDLY[@]} -eq 0 ]; then
ask_string "Could not find disk. Please enter path of devicefile manually" "" || return 1
DISC=${ANSWER_STRING// /} # TODO : some checks if $DISC is really a blockdevice is probably a good idea
else
- DISC=$(echo $BLOCKFRIENDLY | cut -d ' ' -f 1)
+ DISC=${BLOCKFRIENDLY[0]}
fi
get_blockdevice_size $DISC MiB
@@ -330,11 +330,11 @@ interactive_partition() {
# Select disk to partition
listblockfriendly
- DISCS="$BLOCKFRIENDLY OTHER OTHER DONE DONE"
+ DISCS=("${BLOCKFRIENDLY[@]}" OTHER OTHER DONE DONE)
DISC=
while true; do
# Prompt the user with a list of known disks
- ask_option no 'Disc selection' "$question_text (select DONE when finished)" required $DISCS || return 1
+ ask_option no 'Disc selection' "$question_text (select DONE when finished)" required "${DISCS[@]}" || return 1
DISC=$ANSWER_OPTION
if [ "$DISC" = "OTHER" ]; then
ask_string "Enter the full path to the device you wish to partition" "/dev/sda" || return 1
diff --git a/src/core/libs/lib-ui.sh b/src/core/libs/lib-ui.sh
index f31031a..ef0e092 100644
--- a/src/core/libs/lib-ui.sh
+++ b/src/core/libs/lib-ui.sh
@@ -38,16 +38,16 @@ printk()
# Get a list of available partionable blockdevices for use in ask_option
-# populates $BLOCKFRIENDLY with entries like:
-# /dev/sda /dev/sda_640133_MiB_(640_GiB)
+# populates array $BLOCKFRIENDLY with elements like:
+# '/dev/sda' '/dev/sda 640133 MiB (640 GiB)'
listblockfriendly()
{
- BLOCKFRIENDLY=
+ BLOCKFRIENDLY=()
for i in $(finddisks)
do
get_blockdevice_size $i MiB
- [ -n "$BLOCKFRIENDLY" ] && BLOCKFRIENDLY="$BLOCKFRIENDLY "
- BLOCKFRIENDLY="$BLOCKFRIENDLY$i ${i}_${BLOCKDEVICE_SIZE}_MiB_($(($BLOCKDEVICE_SIZE/2**10))_GiB)"
+ size_GiB=$(($BLOCKDEVICE_SIZE/2**10))
+ BLOCKFRIENDLY+=($i "$i ${BLOCKDEVICE_SIZE} MiB ($size_GiB GiB)"
done
}