1
0
mirror of https://github.com/octoleo/hosts.git synced 2024-11-21 20:35:10 +00:00

Rename _load_commands() to _load_subcommands().

This commit is contained in:
William Melody 2020-06-07 14:40:03 -07:00
parent 28fea3a599
commit 379f99f4e1

18
hosts
View File

@ -1587,28 +1587,28 @@ _debug printf \
# Initialize $_DEFINED_COMMANDS array. # Initialize $_DEFINED_COMMANDS array.
_DEFINED_COMMANDS=() _DEFINED_COMMANDS=()
# _load_commands() # _load_subcommands()
# #
# Usage: # Usage:
# _load_commands # _load_subcommands
# #
# Loads all of the commands sourced in the environment. # Loads all of the commands sourced in the environment.
_load_commands() { _load_subcommands() {
_debug printf "_load_commands(): entering...\\n" _debug printf "_load_subcommands(): entering...\\n"
_debug printf "_load_commands() declare -F:\\n%s\\n" "$(declare -F)" _debug printf "_load_subcommands() declare -F:\\n%s\\n" "$(declare -F)"
local _function_list local _function_list
_function_list=($(declare -F)) _function_list=($(declare -F))
_debug printf \ _debug printf \
"_load_commands() \${_function_list[@]}: %s\\n" \ "_load_subcommands() \${_function_list[@]}: %s\\n" \
"${_function_list[@]}" "${_function_list[@]}"
for __name in "${_function_list[@]}" for __name in "${_function_list[@]}"
do do
_debug printf \ _debug printf \
"_load_commands() \${__name}: %s\\n" \ "_load_subcommands() \${__name}: %s\\n" \
"${__name}" "${__name}"
# Each element has the format `declare -f function_name`, so set the name # Each element has the format `declare -f function_name`, so set the name
# to only the 'function_name' part of the string. # to only the 'function_name' part of the string.
@ -1616,7 +1616,7 @@ _load_commands() {
_function_name="$(printf "%s" "${__name}" | awk '{ print $3 }')" _function_name="$(printf "%s" "${__name}" | awk '{ print $3 }')"
_debug printf \ _debug printf \
"_load_commands() \${_function_name}: %s\\n" \ "_load_subcommands() \${_function_name}: %s\\n" \
"${_function_name}" "${_function_name}"
# Add the function name to the $_DEFINED_COMMANDS array unless it starts # Add the function name to the $_DEFINED_COMMANDS array unless it starts
@ -1655,7 +1655,7 @@ _main() {
_SUBCOMMAND="${HOSTS_DEFAULT_SUBCOMMAND}" _SUBCOMMAND="${HOSTS_DEFAULT_SUBCOMMAND}"
fi fi
_load_commands _load_subcommands
if _contains "${_SUBCOMMAND}" "${_DEFINED_COMMANDS[@]:-}" if _contains "${_SUBCOMMAND}" "${_DEFINED_COMMANDS[@]:-}"
then then