bug-bash
[Top][All Lists]
Advanced

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

Re: Functions that update themselves


From: Chet Ramey
Subject: Re: Functions that update themselves
Date: Mon, 3 Jun 2019 15:59:58 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

On 6/3/19 10:46 AM, konsolebox wrote:
> On Mon, Jun 3, 2019 at 9:26 PM Chet Ramey <chet.ramey@case.edu> wrote:
>> It's not disallowed. Since a function definition is a compound command,
>> and all functions are global, I don't see why it shouldn't.
> 
> What I worry about is the way an executable part of the function can
> be freed while the function is being redefined or unset that it may
> cause faults because the code is still being executed.  Bash doesn't
> document its strategy for freeing up function code so whether it's
> safe or not is currently ambiguous.  Perhaps having one last line of
> code to execute after a function is redefined is currently safe, but
> it would be nice if it gets affirmed that it's intended to be.

The function body gets copied before being executed, so the flags and
commands can be modified, just like any other command. I don't see this
ever changing. That's an implementation detail, though.


-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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