What I want trying to achieve is to create a local function within a function. At the same time, the local function will not overwrite the outer function. Below is an example of a simple function and a nested function with argument to illustrate my problem.
#!/bin/bash
usage() #<------------------------------- same function name
{
echo "Overall Usage"
}
function_A()
{
usage() #<--------------------------- same function name
{
echo "function_A Usage"
}
for i in "$@"; do
case $i in
--help)
usage
shift
;;
*)
echo "flag provided but not defined: ${i%%=*}"
echo "See '$0 --help'."
exit 0
;;
esac
done
}
function_A --help
usage
Here is output.
function_A Usage
function_A Usage
But what I want is
function_A Usage
Overall Usage
Is is possible to achieve without change their (functions) name and order? Please?
Note: I tried the local usage()
but it seem not applicable to function.