Check if vars are empty
This commit is contained in:
parent
cfaaac2bba
commit
be99fd38e8
|
@ -85,6 +85,33 @@ error_message() { # {{{
|
|||
exit "${local_error_code:=66}"
|
||||
}
|
||||
# }}}
|
||||
is_var_empty() { # {{{
|
||||
|
||||
## Return False by default
|
||||
return_var_empty="1"
|
||||
## Total number of variables to test
|
||||
local_total_var="${#}"
|
||||
|
||||
loop_count_var_empty="0"
|
||||
|
||||
## While it remains a variable to test
|
||||
while [ "${local_total_var}" -gt "${loop_count_var_empty}" ]; do
|
||||
debug_message "is_var_empty − \
|
||||
Test var: ${1}."
|
||||
### Test if this is empty and set return value to True
|
||||
[ -z "${1}" ] && return_var_empty="0"
|
||||
|
||||
### Increase the number of tested variables
|
||||
loop_count_var_empty=$((loop_count_var_empty+1))
|
||||
|
||||
### Shift to the next variable
|
||||
shift
|
||||
done
|
||||
|
||||
return "${return_var_empty}"
|
||||
|
||||
}
|
||||
# }}}
|
||||
define_vars() { # {{{
|
||||
|
||||
## If adguard_bin wasn't defined (argument,...) {{{
|
||||
|
@ -116,6 +143,17 @@ main() { # {{{
|
|||
## Define all vars according to selected options
|
||||
define_vars
|
||||
|
||||
## Test adguard_current_version
|
||||
## AND exit with error 2
|
||||
is_var_empty "${adguard_current_version}" \
|
||||
&& error_message "adguard_current_version seems empty (${adguard_current_version})." 2
|
||||
|
||||
## Test adguard_new_version
|
||||
## AND exit without error
|
||||
is_var_empty "${adguard_new_version}" \
|
||||
&& debug_message "adguard_new_version seems empty (${adguard_new_version}), exit without error." \
|
||||
&& exit 0
|
||||
|
||||
## Check if the current version is the last one {{{
|
||||
if [ "${adguard_current_version}" != "${adguard_new_version}" ]; then
|
||||
debug_message "Test AdGuard Home version − \
|
||||
|
|
Loading…
Reference in New Issue