You're able to access the parent function name with ${FUNCNAME[1]}
(In BASH, is it possible to get the function name in function body?). Is there a way to also access the parent function argument length (arity)?
So instead of this:
get() {
[ "$#" != 2 ] && exit 1
}
You could do something like this:
get() {
assert_arity 2
}
assert_arity() {
local arity=${parent_function_arity}
local value=$1
[ "${arity}" != "${value}" ] && exit 1
}
Is that possible?