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 recursively
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 recursively.
Apologies.
I think I have said before that I much prefer writing C
Robert Elz wrote:
> The -S flag causes the local variable to be static. When a
> function containing such variables returns, then just before the
> previous values are restored, the current value and attributes of
> each such variable are saved. When the ``local -S variable''
A
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 v
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