Add more validations in getSize() (with a much better regex)
This commit is contained in:
parent
44947d7bf8
commit
dbf735f50b
13
install.sh
13
install.sh
|
@ -120,7 +120,15 @@ partDisks() {
|
||||||
getSize() {
|
getSize() {
|
||||||
sizeStr=$(whiptail --inputbox "Enter the size of the ${1} (in GB)." 0 0 3>&1 1>&2 2>&3)
|
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"
|
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() {
|
createSwapfile() {
|
||||||
|
@ -491,4 +499,5 @@ runScript() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
runScript "$@"
|
# runScript "$@"
|
||||||
|
getSize "Partition"
|
||||||
|
|
Loading…
Reference in New Issue