Fix position of `_read_config` and `_initialize`

This commit is contained in:
rwxrob 2021-08-27 13:11:03 -04:00
parent 77fcc9e6a9
commit f57eb1b80d
No known key found for this signature in database
GPG Key ID: 1CCACEDD2F65578E
1 changed files with 11 additions and 3 deletions

14
cmd
View File

@ -13,6 +13,10 @@ set -e
declare -A HELP declare -A HELP
declare -A CONFIG declare -A CONFIG
_initialize() {
: # put initialization code here
}
HELP[main]=' HELP[main]='
# Bash Template Command # Bash Template Command
@ -35,9 +39,12 @@ tab completion, but will still be there. The `readme` command (which
generates this `README.md` file is a good candidate for this.) generates this `README.md` file is a good candidate for this.)
Be sure to check out the builtin and utility functions. Some of these Be sure to check out the builtin and utility functions. Some of these
can be removed as well if you really want. can be removed as well if you really want.
The `_initialize` function is meant to put initialization code at the
beginning of the script to be found easily even though it is called at
the bottom of the script (as bash requires).
## Naming Conventions ## Naming Conventions
* Name repos containing single bash commands with `cmd-` * Name repos containing single bash commands with `cmd-`
@ -408,6 +415,9 @@ if [[ -n $COMP_LINE ]]; then
exit exit
fi fi
_config_read
_initialize
for c in "${COMMANDS[@]}"; do for c in "${COMMANDS[@]}"; do
if [[ $c == "$EXE" ]]; then if [[ $c == "$EXE" ]]; then
"command_$EXE" "$@" "command_$EXE" "$@"
@ -415,8 +425,6 @@ for c in "${COMMANDS[@]}"; do
fi fi
done done
_config_read
if [[ -n "$1" ]]; then if [[ -n "$1" ]]; then
declare cmd="$1"; shift declare cmd="$1"; shift
for c in "${COMMANDS[@]}"; do for c in "${COMMANDS[@]}"; do