From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18967 invoked from network); 18 May 2005 17:24:36 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 18 May 2005 17:24:36 -0000 Received: (qmail 43761 invoked from network); 18 May 2005 17:24:29 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 May 2005 17:24:29 -0000 Received: (qmail 24309 invoked by alias); 18 May 2005 17:24:22 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8865 Received: (qmail 24296 invoked from network); 18 May 2005 17:24:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 May 2005 17:24:22 -0000 Received: (qmail 42719 invoked from network); 18 May 2005 17:24:22 -0000 Received: from lakermmtao11.cox.net (68.230.240.28) by a.mx.sunsite.dk with SMTP; 18 May 2005 17:24:16 -0000 Received: from quark.hightek.org ([68.12.75.33]) by lakermmtao11.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050518172414.JTFO28600.lakermmtao11.cox.net@quark.hightek.org> for ; Wed, 18 May 2005 13:24:14 -0400 Received: by quark.hightek.org (Postfix, from userid 501) id 105A84592C; Wed, 18 May 2005 12:22:03 -0500 (CDT) Date: Wed, 18 May 2005 12:22:03 -0500 From: Vincent Stemen To: zsh-users@sunsite.dk Subject: Re: variable assignment in a script using globsubst Message-ID: <20050518172202.GA98847@quark.hightek.org> References: <20050518044354.GA96824@quark.hightek.org> <17522.1116409750@csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <17522.1116409750@csr.com> User-Agent: Mutt/1.4.1i X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Wed, May 18, 2005 at 10:49:10AM +0100, Peter Stephenson wrote: > Vincent Stemen wrote: > > Any idea why this works from the command line, > > > > $ setopt globsubst > > $ files=/bin/c*; echo $files > > /bin/cat /bin/chflags /bin/chio /bin/chmod /bin/cp /bin/csh > > > > but in a script, it does not? > > > > The script works if I set globassign in the script, but it assigns it > > as an array rather than a string. However, the manual says, this > > about globassign. > > "This option is provided for backwards compatibility only" > > > > Am I overlooking some other option that could be affecting it? > > No, it must simply be that you have globassign set interactively, e.g. > in .zshrc or /etc/zshrc. It always assigns an array; you'll find > in the interactive case $files[1] is /bin/cat. It's "for backwards > compatibility only" exactly because of this confusion: the syntax says > "scalar", but the glob says "array". > > files=(/bin/c*) > > is the right way to do this. Thanks for the reply Peter. No, I "unsetopt globassign" to make sure, even though it did not show in the list of currently set options, but it still works from the command line. I was trying to do it this way because the script I am working on is running in sh emulation mode and doing it as "files=/bin/c*" assigns it as a single string. I ended up going ahead and changing the one function to zsh mode and doing it as a list to get around the problem, but I wonder if I have stumbled onto a bug here. -- Vincent Stemen Avoid the VeriSign/Network Solutions domain registration trap! Read how Network Solutions (NSI) was involved in stealing our domain name. http://inetaddresses.net/about_NSI.html