Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: unexpected unmodified variable

On 2022-10-06 17:36, Bart Schaefer wrote:
Shrug; shells were originally designed to facilitate text processing
by small independent single-purpose applications.  Everything else is
a bolt-on.

Yes, the ultimate example of accretion.

Playing with that, it seems the last math operation gets to be the rv unless you set a return value, which seems to not go away:

functions -M func2

func2 ()
echo func2 here!
#return 3
func1 ()
local count=1
var=$(( func2() ))
echo var is: $var, count is $count

$  func1
func2 here!
var is: 3, count is 2

... I had : "return 3" active, but commenting it out didn't seem to change anything which is puzzling.  Anyway, it seems that 'count' can be a normal variable just so long as 'func2' is called mathematically.  It's not very intuitive but an interesting party trick just the same.   Or am I missing something as usual?

Messages sorted by: Reverse Date, Date, Thread, Author