From f23cb5b13da347fd978e222fd6e4c9c878f94e25 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 18 2011 22:50:31 +0000 Subject: Update cli_doParseArguments.sh to verify no option is passed twice in the command-line. It was done here to make the verification valid for both common and specific options. --- diff --git a/Scripts/Bash/Functions/cli_doParseArguments.sh b/Scripts/Bash/Functions/cli_doParseArguments.sh index ec13ecd..1f9126e 100755 --- a/Scripts/Bash/Functions/cli_doParseArguments.sh +++ b/Scripts/Bash/Functions/cli_doParseArguments.sh @@ -26,6 +26,27 @@ function cli_doParseArguments { + local ARG1='' + local ARG2='' + local COUNT=0 + + # Verify no option has been passed twice in the command-line. + for ARG1 in $ARGUMENTS;do + ARG1=$(echo $ARG1 | sed -r "s!^'(--[[:alpha:]-]+)=?.+'!\1!") + for ARG2 in $ARGUMENTS;do + ARG2=$(echo $ARG2 | sed -r "s!^'(--[[:alpha:]-]+)=?.+'!\1!") + if [[ $ARG1 == $ARG2 ]];then + COUNT=$(($COUNT + 1)) + fi + #echo "$ARG1 : $ARG2 : $COUNT" + if [[ $COUNT -gt 1 ]];then + cli_printMessage "`eval_gettext "The option \\\`\\\$ARG1' can't be duplicated."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + done + COUNT=0 + done + # Reset positional parameters using optional arguments. eval set -- "$ARGUMENTS"