From 91d1f71624a17ce4cdfc792e1d3b36d5fae3605f Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Wed, 12 Sep 2018 00:08:06 -0600 Subject: [PATCH] Check parameters for empty or '-' contents --- cfddns.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cfddns.sh b/cfddns.sh index 73c5fee..50af580 100755 --- a/cfddns.sh +++ b/cfddns.sh @@ -45,6 +45,17 @@ while getopts ':f:r:' PARAMS; do esac done +# Check validity of parameters +if [ -z "$accountFile" ] || [[ $accountFile == -* ]]; then + echo -e "\e[1;31mNo file containing account details was specified." + echo -e "\e[0;31m(-f parameter empty or missing)\e[0m" + exit 101 +elif [ -z ${dnsRecords} ]; then + echo -e "\e[1;31mNo DNS records were specified." + echo -e "\e[0;31m(-r parameter(s) empty or missing)\e[0m" + exit 102 +fi + ### Echo results (testing) echo "Based on parameters provided:"