Exit with error if new version is empty

This commit is contained in:
Jeremy Gardais 2022-02-01 11:19:40 +01:00
parent 8e7e68c373
commit 1cb1fc0ff5
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
2 changed files with 71 additions and 0 deletions

View File

@ -90,6 +90,33 @@ define_vars() { # {{{
}
# }}}
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}"
}
# }}}
is_file_absent() { # {{{
local_file_absent="${1}"
@ -158,6 +185,12 @@ main() { # {{{
# Define all vars
define_vars
# If cz_version is empty {{{
# Exit with error
is_var_empty "${cz_version}" \
&& error_message "Clonezilla version variable is empty" 6
# }}}
# Create directories and config file
debug_message "Main \
Create ${CZ_INSTALLER_DIR} tree."

View File

@ -110,6 +110,33 @@ define_vars() { # {{{
}
# }}}
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}"
}
# }}}
is_file_absent() { # {{{
local_file_absent="${1}"
@ -178,6 +205,17 @@ main() { # {{{
# Define all vars
define_vars
# If memtest_version is empty {{{
# Exit with error
is_var_empty "${memtest_version}" \
&& error_message "Memtest version variable is empty" 6
# }}}
# If gparted_version is empty {{{
# Exit with error
is_var_empty "${gparted_version}" \
&& error_message "Memtest version variable is empty" 6
# }}}
# Create diagnostic tools directory and config file
mkdir --parents -- "${DIAG_INSTALLER_DIR}" \
|| error_message "Can't create ${DIAG_INSTALLER_DIR}/ directory." 1