Unset var at the end of functions

This commit is contained in:
Jeremy Gardais 2022-12-05 11:48:51 +01:00
parent c30debad59
commit d3fdd52074
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 26 additions and 8 deletions

View File

@ -83,7 +83,6 @@ OPTIONS:
works with NSLCD /etc/nslcd.conf). works with NSLCD /etc/nslcd.conf).
EOF EOF
} }
# }}} # }}}
debug_message() { # {{{ debug_message() { # {{{
@ -93,6 +92,8 @@ debug_message() { # {{{
## Print message if DEBUG is enable (=0) ## Print message if DEBUG is enable (=0)
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG ${PROGNAME}: ${local_message}" [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6b\e[m\n' "DEBUG ${PROGNAME}: ${local_message}"
unset local_message
return 0 return 0
} }
# }}} # }}}
@ -104,6 +105,8 @@ error_message() { # {{{
## Print error message ## Print error message
printf '%b\n' "ERROR ${PROGNAME}: ${RED}${local_error_message}${RESET}" printf '%b\n' "ERROR ${PROGNAME}: ${RED}${local_error_message}${RESET}"
unset local_error_message
exit "${local_error_code:=66}" exit "${local_error_code:=66}"
} }
# }}} # }}}
@ -178,8 +181,10 @@ Test var: ${1}."
shift shift
done done
return "${return_var_empty}" unset local_total_var
unset loop_count_var_empty
return "${return_var_empty}"
} }
# }}} # }}}
is_var_empty_silent() { # {{{ is_var_empty_silent() { # {{{
@ -203,8 +208,10 @@ is_var_empty_silent() { # {{{
shift shift
done done
return "${return_var_empty_silent}" unset local_total_var
unset loop_count_var_empty_silent
return "${return_var_empty_silent}"
} }
# }}} # }}}
is_command_available() { # {{{ is_command_available() { # {{{
@ -224,8 +231,9 @@ ${RED}${local_command_available_cmd}${COLOR_DEBUG} is not available on this host
return_command_available="1" return_command_available="1"
fi fi
return "${return_command_available}" unset local_command_available_cmd
return "${return_command_available}"
} }
# }}} # }}}
is_directory_absent() { # {{{ is_directory_absent() { # {{{
@ -247,8 +255,9 @@ The directory ${RED}${local_directory_absent}${COLOR_DEBUG} exists."
The directory ${RED}${local_directory_absent}${COLOR_DEBUG} doesn't exist." The directory ${RED}${local_directory_absent}${COLOR_DEBUG} doesn't exist."
fi fi
return "${return_is_directory_absent}" unset local_directory_absent
return "${return_is_directory_absent}"
} }
# }}} # }}}
get_ldap_user_list() { # {{{ get_ldap_user_list() { # {{{
@ -280,7 +289,6 @@ Error in ${RED}ldapsearch${COLOR_DEBUG} command for ${ldap_group_cn} LDAP group.
fi fi
return "${return_get_ldap_user_list}" return "${return_get_ldap_user_list}"
} }
# }}} # }}}
is_file_present() { # {{{ is_file_present() { # {{{
@ -302,8 +310,9 @@ The file ${RED}${local_file_present}${COLOR_DEBUG} exists."
The file ${RED}${local_file_present}${COLOR_DEBUG} doesn't exist." The file ${RED}${local_file_present}${COLOR_DEBUG} doesn't exist."
fi fi
return "${return_is_file_present}" unset local_file_present
return "${return_is_file_present}"
} }
# }}} # }}}
is_file_similar() { # {{{ is_file_similar() { # {{{
@ -324,6 +333,9 @@ ${local_similar_file_one} and ${local_similar_file_two} are ${RED}NOT${COLOR_DEB
return_is_file_similar="1" return_is_file_similar="1"
fi fi
unset local_similar_file_one
unset local_similar_file_two
return "${return_is_file_similar}" return "${return_is_file_similar}"
} }
# }}} # }}}
@ -344,6 +356,8 @@ Error in 'mkdir' command for ${RED}${local_directory}${COLOR_DEBUG} directory."
return_create_directory="1" return_create_directory="1"
fi fi
unset local_directory
return "${return_create_directory}" return "${return_create_directory}"
} }
# }}} # }}}
@ -374,12 +388,16 @@ Successfully remove permissions for group and other on ${RED}${local_directory}$
Error in 'chmod' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})." Error in 'chmod' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})."
return_fix_directory_permissions="1" return_fix_directory_permissions="1"
fi fi
## }}}
else else
debug_message "fix_directory_permissions \ debug_message "fix_directory_permissions \
Error in 'chown' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})." Error in 'chown' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})."
return_fix_directory_permissions="1" return_fix_directory_permissions="1"
fi fi
## }}}
unset local_directory
unset local_username
unset local_user_groupname
return "${return_fix_directory_permissions}" return "${return_fix_directory_permissions}"
} }