Add is_var_empty_silent for sensitives variables
This commit is contained in:
parent
c9991761dc
commit
29e64cc35d
|
@ -158,6 +158,31 @@ Test var: ${1}."
|
||||||
|
|
||||||
return "${return_var_empty}"
|
return "${return_var_empty}"
|
||||||
|
|
||||||
|
}
|
||||||
|
# }}}
|
||||||
|
is_var_empty_silent() { # {{{
|
||||||
|
|
||||||
|
## Return False by default
|
||||||
|
return_var_empty_silent="1"
|
||||||
|
## Total number of variables to test
|
||||||
|
local_total_var="${#}"
|
||||||
|
|
||||||
|
loop_count_var_empty_silent="0"
|
||||||
|
|
||||||
|
## While it remains a variable to test
|
||||||
|
while [ "${local_total_var}" -gt "${loop_count_var_empty_silent}" ]; do
|
||||||
|
### Test if this is empty and set return value to True
|
||||||
|
[ -z "${1}" ] && return_var_empty_silent="0"
|
||||||
|
|
||||||
|
### Increase the number of tested variables
|
||||||
|
loop_count_var_empty_silent=$((loop_count_var_empty_silent+1))
|
||||||
|
|
||||||
|
### Shift to the next variable
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
return "${return_var_empty_silent}"
|
||||||
|
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
main() { # {{{
|
main() { # {{{
|
||||||
|
@ -165,13 +190,20 @@ main() { # {{{
|
||||||
## Define all vars
|
## Define all vars
|
||||||
define_vars
|
define_vars
|
||||||
|
|
||||||
## If ldap_group_cn is empty
|
## If ldap_group_cn is empty {{{
|
||||||
### Print help message
|
### Print help message
|
||||||
### AND exit with message and error
|
### AND exit with message and error
|
||||||
is_var_empty "${ldap_group_cn}" \
|
is_var_empty "${ldap_group_cn}" \
|
||||||
&& usage \
|
&& usage \
|
||||||
&& error_message "Please enter a GROUP with -g|--group option." "1"
|
&& error_message "Please enter a GROUP with -g|--group option." "1"
|
||||||
|
## }}}
|
||||||
|
## If ldap_user or ldap_passwd is empty {{{
|
||||||
|
### Print help message
|
||||||
|
### AND exit with message and error
|
||||||
|
is_var_empty_silent "${ldap_user}" "${ldap_passwd}" \
|
||||||
|
&& usage \
|
||||||
|
&& error_message "LDAP user or password is empty. Please verify your configuration or the --user-cmd|--passwd-cmd options." "2"
|
||||||
|
## }}}
|
||||||
|
|
||||||
## Information message
|
## Information message
|
||||||
debug_message "Search for members in ${RED}${ldap_group_cn},${ldap_group_base}${COLOR_DEBUG} group \
|
debug_message "Search for members in ${RED}${ldap_group_cn},${ldap_group_base}${COLOR_DEBUG} group \
|
||||||
|
|
Loading…
Reference in New Issue