From d487df8c9ecf58af3ab46e7f2b898a9b4f6ba097 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Sun, 12 Dec 2010 20:33:15 +0100 Subject: make BLOCKFRIENDLY prettier use arrays, so we can allow whitespace in the labels --- src/core/libs/lib-ui-interactive.sh | 12 ++++++------ src/core/libs/lib-ui.sh | 10 +++++----- 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 } -- cgit v1.2.3-54-g00ecf