Re: Functions that update themselves

2019-06-03 Thread Chet Ramey
On 6/3/19 10:46 AM, konsolebox wrote: > On Mon, Jun 3, 2019 at 9:26 PM Chet Ramey 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 c

Re: Functions that update themselves

2019-06-03 Thread konsolebox
On Mon, Jun 3, 2019 at 9:26 PM Chet Ramey 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 redefi

Re: Functions that update themselves

2019-06-03 Thread Chet Ramey
On 6/3/19 3:54 AM, konsolebox wrote: > Hi Chet, > > Do you explicitly allow functions to do this? 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. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

Re: Functions that update themselves

2019-06-03 Thread Andreas Kusalananda Kähäri
On Mon, Jun 03, 2019 at 03:54:59PM +0800, konsolebox wrote: > Hi Chet, > > Do you explicitly allow functions to do this? I just want to know. > > a() { a() { ...; }; a; } > b() { unset -f b; command b "$@"; } > > My current use case for this is to have a function simplify itself > when conditio

Functions that update themselves

2019-06-03 Thread konsolebox
Hi Chet, Do you explicitly allow functions to do this? I just want to know. a() { a() { ...; }; a; } b() { unset -f b; command b "$@"; } My current use case for this is to have a function simplify itself when condition checks are no longer necessary and just adds unnecessary runtime load. I al