dynamic_main: Fix array size check, write test case

This commit is contained in:
Andrea Rogers 2023-10-31 21:41:51 -05:00
commit 282c2f5b04
2 changed files with 7 additions and 2 deletions

View file

@ -1,7 +1,7 @@
command -v dedcat || \ command -v dedcat || \
source "$(dirname ${BASH_SOURCE[0]})/logging.bash" source "$(dirname ${BASH_SOURCE[0]})/logging.bash"
[ -z "${fns[@]}" ] && dedcat 'ERROR: Empty or undefined ${fns[@]} array!' [ "${#fns[@]}" -gt 0 ] || dedcat 'ERROR: Empty or undefined ${fns[@]} array!'
read -d '' HELPSTR <<EOH read -d '' HELPSTR <<EOH
Usage: $0 OPERATION Usage: $0 OPERATION

View file

@ -1,10 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
fns=( hello ) fns=( hello hi )
hello() { hello() {
[ "$1" == help ] && echo -n "Say \"hello.\"" && return 0 [ "$1" == help ] && echo -n "Say \"hello.\"" && return 0
echo hello. echo hello.
} }
hi() {
[ "$1" == help ] && echo -n "Say \"hi.\"" && return 0
echo hi.
}
. "$(dirname "$0")/../dynamic_main.bash" . "$(dirname "$0")/../dynamic_main.bash"