Commit e1b74bad authored by Cristian Weiland's avatar Cristian Weiland

Merge branch 'issue/72' into 'develop'

Issue #72: Treating wrong inputs.

See merge request !35
parents 8ebb4f65 6108b3c7
......@@ -30,6 +30,25 @@
user=$3
passwd=$4
# Treating the cases where the year input is invalid
if [[ "${#year}" != "4" ]]; then
echo " Year is invalid. Please enter a 4 digit year."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where month is too big
if [[ "${#month}" -gt "2" ]]; then
echo " Month is invalid. Please enter a 2 digit month."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where the user uses only 1 digit to the month value
if [[ "${#month}" -eq "1" ]]; then
month="0$month"
fi
source ./config.sh
# Check if all variables in config file are set:
......
......@@ -20,6 +20,25 @@ user=$3
passwd=$4
insertions=$5
# Treating the cases where the year input is invalid
if [[ "${#year}" != "4" ]]; then
echo " Year is invalid. Please enter a 4 digit year."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where month is too big
if [[ "${#month}" -gt "2" ]]; then
echo " Month is invalid. Please enter a 2 digit month."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where the user uses only 1 digit to the month value
if [[ "${#month}" -eq "1" ]]; then
month="0$month"
fi
if [[ "$insertions" == "all" || "$insertions" == "expenses" ]]; then
# First, insert Expenses data.
echo "Inserting Expenses from ${year}-${month}..."
......
......@@ -29,6 +29,25 @@ month=$2
user=$3
passwd=$4
# Treating the cases where the year input is invalid
if [[ "${#year}" != "4" ]]; then
echo " Year is invalid. Please enter a 4 digit year."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where month is too big
if [[ "${#month}" -gt "2" ]]; then
echo " Month is invalid. Please enter a 2 digit month."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where the user uses only 1 digit to the month value
if [[ "${#month}" -eq "1" ]]; then
month="0$month"
fi
source ./config.sh
# Check if all variables in config file are set:
......
......@@ -33,7 +33,27 @@ month=$2
user=$3
passwd=$4
# Treating the cases where the year input is invalid
if [[ "${#year}" != "4" ]]; then
echo " Year is invalid. Please enter a 4 digit year."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where month is too big
if [[ "${#month}" -gt "2" ]]; then
echo " Month is invalid. Please enter a 2 digit month."
echo " Example: $0 2016 12 myuser mypass all"
exit
fi
# Treating the case where the user uses only 1 digit to the month value
if [[ "${#month}" -eq "1" ]]; then
month="0$month"
fi
source ./config.sh
configFile='scripts/workers/config.sh'
if [ -z "${index}" ]; then
inputError "index" $configFile
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment