On 2022-10-07 13:00, Bart Schaefer wrote:
... which might just be the most impenetrable bit of computer bafflegab I've ever read, I can't get past the first sentence.True ... which makes the manual hard to understand. It's a language unto itself. What would be helpful is some sort of introduction to zsh-speak. Mind, I expect all the shells have about the same jargon. But believe me, when you don't know the lingo it's impenetrable.Seriously? This is all using phrases that refer to concepts appearing elsewhere throughout the zsh manual.
Oh. Given the way you wrote func2, if you remove the return statement there are NO math expressions in func2 at all, so $(( func2() )) is [except for side-effects] a no-op, and the assignment in var=$(( func2() )) is just skipped, leaving the previous value of $var unchanged.
Ah! ... yes, why would it change? nothing has touched it. I was expecting func2 to somehow cough up a null value setting 'var=0' but it's not illogical that it coughs up ... nothing ... therefore there is no assignment and 'var' does not change. I get it.
Well you'd know. Anyway as usual the functionality I was looking for is there even if it didn't look like I expected. By now I should have a permanent understanding of this stuff not keep relapsing."Local" text substitution is what ordinary $param references are for ... $(...) specifically means to use processes and pipes. That said, a still-missing feature in zsh is the ability to tie a function to a variable so that referencing the variable as $foo invokes the function that's tied to it, to produce the effect you're asking for. Ksh has a syntax for that.