zsh-users
 help / color / mirror / code / Atom feed
* unexpected unmodified variable
@ 2022-10-06 19:07 Ray Andrews
  2022-10-06 19:28 ` Peter Stephenson
  0 siblings, 1 reply; 9+ messages in thread
From: Ray Andrews @ 2022-10-06 19:07 UTC (permalink / raw)
  To: Zsh Users


func2 ()
{
count=2
echo from func2: $count
}

func1 ()
{
local count=1
func2
echo from func1: $count
count=1
var=$( func2 )
echo from func1: $count
echo var is: $var
}

$ func1
from func2: 2
from func1: 2
from func1: 1
var is: from func2: 2

... This catches me by surprise; when " var =$( func2 ) " happens I'm 
expecting 'func2' to do everything it does including reset 'count' to 
'2'.  Why doesn't it, and is there any way to solve that?  Hacking around:

func1 ()
{
local count=1
func2 > /dev/null

func2

}

... performs as I'm wanting it to but it's a bit disgusting.







^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-10-07 21:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-06 19:07 unexpected unmodified variable Ray Andrews
2022-10-06 19:28 ` Peter Stephenson
2022-10-06 21:58   ` Ray Andrews
2022-10-07  0:36     ` Bart Schaefer
2022-10-07  1:37       ` Ray Andrews
2022-10-07  4:36         ` Bart Schaefer
2022-10-07 15:28           ` Ray Andrews
2022-10-07 20:00             ` Bart Schaefer
2022-10-07 21:59               ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).