Ensure arguments have expected values

This commit is contained in:
Jeremy Gardais 2020-02-27 16:04:49 +01:00
parent fafd2cfc20
commit cf12d2bcd9
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 32 additions and 19 deletions

View File

@ -40,6 +40,18 @@ EXAMPLE:
HELP HELP
} }
## ]]] ## ]]]
## Check arguments [[[
## Ensure arguments have the expected value
check_arguments() {
if ! printf -- '%s' "${test_to_run}" | grep -q -E -- "(short|long)"; then
printf "${c_redb}%-6b${c_reset}\n" "ERROR: Can't manage '${test_to_run}' test type."
print_help_message
exit 3
fi
}
## ]]]
## Manage the arguments [[[ ## Manage the arguments [[[
manage_arguments() { manage_arguments() {
_nb_arg="${#}" _nb_arg="${#}"
@ -55,7 +67,7 @@ manage_arguments() {
exit 0 exit 0
fi fi
## ]]] ## ]]]
# Manage arguments [[[ ## Manage arguments [[[
case "${_nb_arg}" in case "${_nb_arg}" in
0 ) 0 )
## Set test to run to default (short) ## Set test to run to default (short)
@ -70,8 +82,9 @@ case "${_nb_arg}" in
exit 2 exit 2
;; ;;
esac esac
# ]]] ## ]]]
## Verify the content of arguments
check_arguments
} }
## ]]] ## ]]]
## Test if a disk really support SMART [[[ ## Test if a disk really support SMART [[[