[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFE? request for an "undefined" attribute for functions

From: Bernd Eggink
Subject: Re: RFE? request for an "undefined" attribute for functions
Date: Mon, 02 Aug 2010 18:26:20 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de; rv: Gecko/20100713 Thunderbird/3.1.1

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" 
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
        eval "function $name
            source $FUNCDIR/$name
            $name \"address@hidden"

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).


Bernd Eggink

reply via email to

[Prev in Thread] Current Thread [Next in Thread]