i implemented a similar idea to this here https://github.com/MayCXC/envy/blob/master/envy.sh#L45
it pretty much declares a counter and new function, f_0 f_1 f_2... every time a function is given another definition. then f calls the most recent definition, and f_ calls the previous definition. i had to make some pretty extravagant use of eval to get it to work in posix sh, but i think you could do something cleaner for bash with local and perhaps arrays.
i implemented a similar idea to this here https://github.com/MayCXC/envy/blob/master/envy.sh#L45
it pretty much declares a counter and new function, f_0 f_1 f_2... every time a function is given another definition. then f calls the most recent definition, and f_ calls the previous definition. i had to make some pretty extravagant use of
evalto get it to work in posix sh, but i think you could do something cleaner for bash withlocaland perhaps arrays.