My favourite shell scripting function definition technique: idempotent functions by redefining the function as a noop inside its body:
foo() {
foo() { true; }
echo "This bit will only be executed on the first foo call"
}
(The `true;` body is needed by some shells, e.g. bash, and not others, e.g. zsh.)