Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
unexpected unmodified variable
- X-seq: zsh-users 28191
- From: Ray Andrews <rayandrews@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: unexpected unmodified variable
- Date: Thu, 6 Oct 2022 12:07:43 -0700
- Archived-at: <https://zsh.org/users/28191>
- List-id: <zsh-users.zsh.org>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author