Re: Add static local vars to sh(1) ?

2018-01-29 Thread Valery Ushakov
On Mon, Jan 29, 2018 at 23:33:25 +0700, Robert Elz wrote: > From: u...@stderr.spb.ru (Valery Ushakov) > Subject: Re: Add static local vars to sh(1) ? > Date: Mon, 29 Jan 2018 13:38:25 + (UTC) > > | This doesn't seem to mention what happens when the > | function is called

Re: Add static local vars to sh(1) ?

2018-01-29 Thread Rhialto
On Mon 29 Jan 2018 at 15:40:28 +0700, Robert Elz wrote: > sh -c 'fn() { unset -f fn; echo done; }; fn' > > This just says "done" - but obviously when the "echo done" is performed, > fn has already been removed. You can test this with any NetBSD sh version. I tried it on a Linux bash with

Add static local vars to sh(1) ?

2018-01-29 Thread Robert Elz
For an (irrelevant here) script, I had an issue that would be best handled by having static local (to a function) sh vars (normally handled by just using a global, but that raises namespace issues.) So, I wondered how easy it would be to add static local vars to sh. It turns out to be quite easy