I implement a lot of things via (bash) shell functions.
I keep them stored in files in a directory called ~/bash_functions, and I have
code
in .bash_aliases to load (i.e., source, aka "dot") every file in that directory.
I usually have lots of shells open in various windows (and SSH sessions).
It all works very well, except...
One of the issues I frequently face is that if I edit the function definition,
then I
need to re-source the file in every shell session, or else that shell will be
running
an out-of-date version. This is, of course, a PITA, and there's no good way to
tell
whether or not you're running an old version. Now, of course, one approach is
"When
in doubt, re-source", but that's obviously less than ideal.
Now, what I would like to see is some built-in support for this in bash itself.
At a minimum, it seems to me that if bash would record somewhere a table of
when each
function was most recently defined, then it should be possible to put code in
the
function itself to check to see if the file is newer than the "last definition
time"
and react accordingly. Even better would be if bash would also record from
which
file the definition came.
This could be implemented as associative arrays, with the key being the
function name
and the value being the timestamp (or the filename).