diff --git a/install.sh b/install.sh index 697d129..5dd3d97 100755 --- a/install.sh +++ b/install.sh @@ -120,7 +120,15 @@ partDisks() { getSize() { sizeStr=$(whiptail --inputbox "Enter the size of the ${1} (in GB)." 0 0 3>&1 1>&2 2>&3) exitIfCancel "You must enter a size." "partDisks" - echo "$sizeStr" | awk -F'[^0-9.,]+' '{ print $1 }' + size=$(echo "$sizeStr" | grep -Eo '[-]?[0-9]+([.,]?[0-9]+)?' | head -n1 | sed 's/,/./g' | awk '{ print int($1 * 1024) }') + while [ $(echo $size | awk '{ print $1 <= 0 }') -eq 1 ]; do + sizeStr=$(whiptail --inputbox "Size cannot be less than or equal to zero. Please enter a new size." 0 0 3>&1 1>&2 2>&3) + exitIfCancel "You must enter a size." "partDisks" + #calcHeightAndRun "whiptail --inputbox \"Size cannot be less than or equal to zero. Please enter a new size.\" HEIGHT 60 3>&1 1>&2 2>&3" + size=$(echo "$sizeStr" | grep -Eo '[-]?[0-9]+([.,]?[0-9]+)?' | head -n1 | sed 's/,/./g' | awk '{ print int($1 * 1024) }') + echo $size | awk '{ print $1 <= 0 }' + done + echo $size } createSwapfile() { @@ -491,4 +499,5 @@ runScript() { done } -runScript "$@" +# runScript "$@" +getSize "Partition"