Ensure arguments have expected values
This commit is contained in:
parent
fafd2cfc20
commit
cf12d2bcd9
|
@ -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="${#}"
|
||||||
|
@ -47,16 +59,16 @@ manage_arguments() {
|
||||||
|
|
||||||
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : manage_arguments func − ${_nb_arg} argument(s) to manage. List:\n ${_all_args}"
|
[ "${debug}" -eq "0" ] && printf "${c_magentab}%-6b${c_reset}\n" "DEBUG : manage_arguments func − ${_nb_arg} argument(s) to manage. List:\n ${_all_args}"
|
||||||
|
|
||||||
## If help is needed [[[
|
## If help is needed [[[
|
||||||
if printf -- '%s' "${_all_args}" | grep -q -E -- "-h|--help|help"; then
|
if printf -- '%s' "${_all_args}" | grep -q -E -- "-h|--help|help"; then
|
||||||
|
|
||||||
print_help_message
|
print_help_message
|
||||||
|
|
||||||
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)
|
||||||
test_to_run="short"
|
test_to_run="short"
|
||||||
|
@ -69,9 +81,10 @@ case "${_nb_arg}" in
|
||||||
print_help_message
|
print_help_message
|
||||||
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 [[[
|
||||||
|
|
Loading…
Reference in New Issue