input validation
This commit is contained in:
parent
c44e09e300
commit
dd14c6665c
@ -30,9 +30,8 @@ menu(){
|
|||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups
|
read -rt 600 -p "Please type the max number of backups to keep: " number_of_backups
|
||||||
re='^[0-9]+$'
|
|
||||||
number_of_backups=$number_of_backups
|
number_of_backups=$number_of_backups
|
||||||
! [[ $number_of_backups =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit
|
! [[ $number_of_backups =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit
|
||||||
[[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit
|
[[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit
|
||||||
echo "Generating backup, please be patient for output.."
|
echo "Generating backup, please be patient for output.."
|
||||||
backup "$number_of_backups"
|
backup "$number_of_backups"
|
||||||
@ -107,6 +106,7 @@ menu(){
|
|||||||
elif [[ $current_selection == 1 ]]; then
|
elif [[ $current_selection == 1 ]]; then
|
||||||
echo "Up to how many backups should we keep?"
|
echo "Up to how many backups should we keep?"
|
||||||
read -rt 600 -p "Please type an integer: " up_backups
|
read -rt 600 -p "Please type an integer: " up_backups
|
||||||
|
! [[ $up_backups =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_backups\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue
|
||||||
update_selection+=("-b" "$up_backups")
|
update_selection+=("-b" "$up_backups")
|
||||||
elif [[ $current_selection == 2 ]]; then
|
elif [[ $current_selection == 2 ]]; then
|
||||||
read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore
|
read -rt 600 -p "What is the name of the application we should ignore?: " up_ignore
|
||||||
@ -120,6 +120,7 @@ menu(){
|
|||||||
elif [[ $current_selection == 6 ]]; then
|
elif [[ $current_selection == 6 ]]; then
|
||||||
echo "What do you want your timeout to be?"
|
echo "What do you want your timeout to be?"
|
||||||
read -rt 600 -p "Please type an integer: " up_timeout
|
read -rt 600 -p "Please type an integer: " up_timeout
|
||||||
|
! [[ $up_timeout =~ ^[0-9]+$ ]] && echo -e "Error: \"$up_timeout\" is invalid, it needs to be an integer\nNOT adding it to the list" && sleep 5 && continue
|
||||||
update_selection+=("-t" "$up_timeout")
|
update_selection+=("-t" "$up_timeout")
|
||||||
elif [[ $current_selection == 7 ]]; then
|
elif [[ $current_selection == 7 ]]; then
|
||||||
update_selection+=("-s")
|
update_selection+=("-s")
|
||||||
|
@ -56,9 +56,8 @@ do
|
|||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
b)
|
b)
|
||||||
re='^[0-9]+$'
|
|
||||||
number_of_backups=$OPTARG
|
number_of_backups=$OPTARG
|
||||||
! [[ $OPTARG =~ $re ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit
|
! [[ $OPTARG =~ ^[0-9]+$ ]] && echo -e "Error: -b needs to be assigned an interger\n\"""$number_of_backups""\" is not an interger" >&2 && exit
|
||||||
[[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit
|
[[ "$number_of_backups" -le 0 ]] && echo "Error: Number of backups is required to be at least 1" && exit
|
||||||
;;
|
;;
|
||||||
r)
|
r)
|
||||||
@ -77,9 +76,8 @@ do
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
t)
|
t)
|
||||||
re='^[0-9]+$'
|
|
||||||
timeout=$OPTARG
|
timeout=$OPTARG
|
||||||
! [[ $timeout =~ $re ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit
|
! [[ $timeout =~ ^[0-9]+$ ]] && echo -e "Error: -t needs to be assigned an interger\n\"""$timeout""\" is not an interger" >&2 && exit
|
||||||
;;
|
;;
|
||||||
s)
|
s)
|
||||||
sync="true"
|
sync="true"
|
||||||
|
Loading…
Reference in New Issue
Block a user