-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.bash
More file actions
52 lines (44 loc) · 1.36 KB
/
dev.bash
File metadata and controls
52 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
function dev_test_fn() { ## Directly run a specific function.
if [[ ! ( -v '1' && -n "$1" ) ]]; then
echo 'No target function name was provided to `test_fn`.' >&2
terminate
fi
local fn="$1"
if is_function_defined "$fn"; then
shift
"$fn" "$@"
else
echo "No definition for specified function: \"$fn\""
terminate
fi
}
function dev_list_nop_fn() { ## List functions not included in the PrimaryOperations array.
local -a nop_fns=()
while read -r line; do
## Buffer only the last (right-most) whitespace delimited string.
buff="${line##* }"
for op in "${PrimaryOperations[@]}"; do
if [[ "$op" == "$buff" ]]; then
## Skip this function name.
continue 2
fi
done
## Buffered function name is not in PrimaryOperations array.
nop_fns+=("$buff")
done < <(declare -F)
if (( ${#nop_fns} )); then
echo 'Defined functions not declared in PrimaryOperations array:'
for fn in "${nop_fns[@]}"; do
echo -e "\t$fn"
done
else
echo 'No functions defined other than those in the PrimaryOperations array.'
fi
}
## Append functions starting with "dev_" to array of valid operations.
## Underscores in function names are translated to hyphens for invocation.
while read -r fn; do
Operations+=(["${fn//_/-}"]="dev_$fn")
done < <(compgen -A function -X '!dev_*')
#done < <(compgen -A function -X '!dev_*' | cut -c 5-) ## 5=sizeof("dev_")