Am 02.08.2010 03:10, schrieb Linda Walsh:
I had(have) several functions that I don't use on a regular basis (rarely), that
I had put into a subdir "func_lib" under my local-definitions directory.
This came from ksh, which allows you to define functions with an "undef"
attribute,
and at runtime, the first time these functions were referenced,
Is this something that might have been considered for bash? It seems like it
could have some usefulness?
If you are concerned about memory usage, you could use a mechanism like
this:
#-------------------------------------
function undef
{
local name
for name
do
eval "function $name
{
source $FUNCDIR/$name
$name \"\...@\"
}"
done
}
#-------------------------------------
The call
undef f1 f2 f3
(corresponding to 'autoload f1 f2 f3' in ksh) creates small placeholder
functions f1, f2, and f3. The first call to any of these functions will
replace its definition by the one found in $FUNCDIR, and also call the
latter.
I'm not sure, however, if this is guaranteed to work in any case (and in
any bash version).
Greetings,
Bernd
--
Bernd Eggink
http://sudrala.de