From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24312 invoked by alias); 9 Aug 2015 00:31:54 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20398 Received: (qmail 23028 invoked from network); 9 Aug 2015 00:31:52 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=5x1XyepjdM53uGIlAgGGgqbBDBzbIhuIKmxgSXYkpqw=; b=Y/ymY+QMrjOTZ7XeOwNXb8uqMux7BBpc19BXP11RoUXPM/9X/qCsDiTt/Hq62GwMT9 PsCcjQJJC2QAuOfNzrC1H24rvAdn/4+Xx9GK2WoOavn+HRTLyZ6DVrJfOWwbC42yaMFj K75cuSrjmTQ0yvf7S7inCf350tNU3EGhpEENKNMKQ+RfYMjZWtcbihW3dvuVCMPtanMP JWNV5tCh+x1eDguNUKyih4N8O+F3HUvU9RtvPqqos07y4c8COmvJna8rwUIWksdGDx4q 2r+lcIyAE1Lucd4u4NHYBpm/B9diRKYWYtp0McjHw1xbxFaRVBLNEAcRJW5Lbsj4KGCJ ld0A== X-Gm-Message-State: ALoCoQmPTNWrxDhfhg8gPCYhSeJM4mtwwkjsGCHbD4iHJEke/ulTV7TU0uFIqCtxWJEIxKjtMZrW X-Received: by 10.60.16.228 with SMTP id j4mr14050283oed.59.1439080311162; Sat, 08 Aug 2015 17:31:51 -0700 (PDT) From: Bart Schaefer Message-Id: <150808173147.ZM14125@torch.brasslantern.com> Date: Sat, 8 Aug 2015 17:31:47 -0700 In-Reply-To: <55C68669.8000408@netcologne.de> Comments: In reply to Georg Wittig "Global And Local Variables in zsh Functions" (Aug 9, 12:44am) References: <55C68669.8000408@netcologne.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Global And Local Variables in zsh Functions MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Aug 9, 12:44am, Georg Wittig wrote: } } x1=$(my_f2 /tmp) } x2=$(my_f2 /opt/windows7) } } To my surprise, EXC is empty now: } } Why is EXC empty in the case of my_f2, and correct in the case my_f1? The use of $(...) means your my_f2 function runs in a forked child process, and so changes to variables are not visible to the parent shell. If you want my_f2 to work like my_f1, you'll have to do something like function my_f2 () { EXC+=" --exclude='$1'"; typeset -g $2="some value depending on $1" } my_f2 /tmp x1 my_f2 /opt/windows7 x2