From ff865f7484dbebbc3915a1b46cc02a35d201ed06 Mon Sep 17 00:00:00 2001 From: aminnairi <18418459+aminnairi@users.noreply.github.com> Date: Thu, 4 Jan 2024 12:31:12 +0100 Subject: [PATCH] now the script will bail out if it has been provided with too much arguments --- main.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/main.sh b/main.sh index dc9ef27..0e40746 100755 --- a/main.sh +++ b/main.sh @@ -2,9 +2,10 @@ ERROR_BECAUSE_ROOT=1 ERROR_BECAUSE_NOT_ARCH_LINUX=2 -ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED=3 -ERROR_BECAUSE_PLAYBOOK_INVALID_OR_NOT_FOUND=4 -ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST=5 +ERROR_BECAUSE_TOO_MUCH_ARGUMENTS_PROVDED=3 +ERROR_BECAUSE_ANSIBLE_INSTALLATION_FAILED=5 +ERROR_BECAUSE_PLAYBOOK_INVALID_OR_NOT_FOUND=5 +ERROR_BECAUSE_PLAYBOOK_PATH_DOES_NOT_EXIST=6 if [[ "$(id -u)" -eq 0 ]] then @@ -29,6 +30,12 @@ then fi fi +if [[ $# -gt 1 ]] +then + echo "Too much arguments provided." + exit $ERROR_BECAUSE_TOO_MUCH_ARGUMENTS_PROVDED +fi + choosen_playbook_path=$1 if [[ -z $choosen_playbook_path ]]