I have a nest of bash scripts that can source each other, e.g. a.sh sources b.sh sources a.sh etc... Other than redesigning, which may not always be feasible, what are the best practices for avoiding a source loop?
One approach I have is to use the presence of a given function that indicates, not to source this scrip again. e.g.
a.sh:
declare -F a
if [ $? -eq 0 ]
then
return
fi
...
function a()
{
}
another is to have some per file variable "$sourced_a_sh" and if set return.
They all seem pretty kludgy however. Is there a nicer way?