From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11256 invoked from network); 18 May 2005 04:46: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 04:46:36 -0000 Received: (qmail 61800 invoked from network); 18 May 2005 04:46:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 May 2005 04:46:23 -0000 Received: (qmail 14492 invoked by alias); 18 May 2005 04:46:15 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8861 Received: (qmail 14479 invoked from network); 18 May 2005 04:46:13 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 May 2005 04:46:13 -0000 Received: (qmail 60695 invoked from network); 18 May 2005 04:46:13 -0000 Received: from lakermmtao12.cox.net (68.230.240.27) by a.mx.sunsite.dk with SMTP; 18 May 2005 04:46:07 -0000 Received: from quark.hightek.org ([68.12.75.33]) by lakermmtao12.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050518044606.FDHA10612.lakermmtao12.cox.net@quark.hightek.org> for ; Wed, 18 May 2005 00:46:06 -0400 Received: by quark.hightek.org (Postfix, from userid 501) id 1C06E4592B; Tue, 17 May 2005 23:43:55 -0500 (CDT) Date: Tue, 17 May 2005 23:43:55 -0500 From: Vincent Stemen To: zsh-users@sunsite.dk Subject: variable assignment in a script using globsubst Message-ID: <20050518044354.GA96824@quark.hightek.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 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? # ---- Output of the script: /etc/c* I got the same result on both Linux and BSD. 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? -- 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23269 invoked from network); 18 May 2005 09:49:40 -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 09:49:40 -0000 Received: (qmail 98467 invoked from network); 18 May 2005 09:49:34 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 May 2005 09:49:34 -0000 Received: (qmail 24755 invoked by alias); 18 May 2005 09:49:23 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8862 Received: (qmail 24735 invoked from network); 18 May 2005 09:49:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 May 2005 09:49:22 -0000 Received: (qmail 97191 invoked from network); 18 May 2005 09:49:22 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 18 May 2005 09:49:11 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Wed, 18 May 2005 10:47:23 +0100 Received: from csr.com ([10.102.144.127]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 18 May 2005 10:50:34 +0100 To: zsh-users@sunsite.dk Subject: Re: variable assignment in a script using globsubst In-Reply-To: Message from Vincent Stemen of "Tue, 17 May 2005 23:43:55 CDT." <20050518044354.GA96824@quark.hightek.org> References: <20050518044354.GA96824@quark.hightek.org> Date: Wed, 18 May 2005 10:49:10 +0100 Message-ID: <17522.1116409750@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 18 May 2005 09:50:34.0940 (UTC) FILETIME=[0998FFC0:01C55B8F] 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 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. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. ********************************************************************** 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4055 invoked from network); 18 May 2005 17:50:02 -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:50:02 -0000 Received: (qmail 79889 invoked from network); 18 May 2005 17:49:56 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 18 May 2005 17:49:56 -0000 Received: (qmail 12119 invoked by alias); 18 May 2005 17:49:40 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8866 Received: (qmail 12060 invoked from network); 18 May 2005 17:49:39 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 18 May 2005 17:49:39 -0000 Received: (qmail 76967 invoked from network); 18 May 2005 17:49:38 -0000 Received: from mailhost1.csr.com (HELO MAILSWEEPER01.csr.com) (81.105.217.43) by a.mx.sunsite.dk with SMTP; 18 May 2005 17:49:27 -0000 Received: from exchange03.csr.com (unverified [10.100.137.60]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Wed, 18 May 2005 18:47:39 +0100 Received: from csr.com ([10.102.144.127]) by exchange03.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Wed, 18 May 2005 18:50:51 +0100 To: zsh-users@sunsite.dk Subject: Re: variable assignment in a script using globsubst In-Reply-To: Message from Vincent Stemen of "Wed, 18 May 2005 12:22:03 CDT." <20050518172202.GA98847@quark.hightek.org> References: <20050518044354.GA96824@quark.hightek.org> <17522.1116409750@csr.com> <20050518172202.GA98847@quark.hightek.org> Date: Wed, 18 May 2005 18:49:25 +0100 Message-ID: <18909.1116438565@csr.com> From: Peter Stephenson X-OriginalArrivalTime: 18 May 2005 17:50:51.0798 (UTC) FILETIME=[21C89360:01C55BD2] 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 Vincent Stemen wrote: > 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. Do you have globsubst set? In that case, files will be set to /bin/c* but "echo $files" would expand the glob at that point. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. ********************************************************************** From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28461 invoked from network); 19 May 2005 18:31:04 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 19 May 2005 18:31:04 -0000 Received: (qmail 64010 invoked from network); 19 May 2005 18:30:57 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 19 May 2005 18:30:56 -0000 Received: (qmail 23414 invoked by alias); 19 May 2005 18:30:49 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8872 Received: (qmail 23405 invoked from network); 19 May 2005 18:30:49 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 19 May 2005 18:30:49 -0000 Received: (qmail 62989 invoked from network); 19 May 2005 18:30:49 -0000 Received: from lakermmtao05.cox.net (68.230.240.34) by a.mx.sunsite.dk with SMTP; 19 May 2005 18:30:43 -0000 Received: from quark.hightek.org ([68.12.75.33]) by lakermmtao05.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050519183041.ORFI13442.lakermmtao05.cox.net@quark.hightek.org> for ; Thu, 19 May 2005 14:30:41 -0400 Received: by quark.hightek.org (Postfix, from userid 501) id 1BBB945933; Thu, 19 May 2005 13:28:20 -0500 (CDT) Date: Thu, 19 May 2005 13:28:20 -0500 From: Vincent Stemen To: zsh-users@sunsite.dk Subject: Re: variable assignment in a script using globsubst Message-ID: <20050519182820.GA3586@quark.hightek.org> References: <20050518044354.GA96824@quark.hightek.org> <17522.1116409750@csr.com> <20050518172202.GA98847@quark.hightek.org> <18909.1116438565@csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18909.1116438565@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 06:49:25PM +0100, Peter Stephenson wrote: > Vincent Stemen wrote: > > 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. > > Do you have globsubst set? In that case, files will be set to /bin/c* > but "echo $files" would expand the glob at that point. Yes. That is what was happening. I was thinking globsubst would cause it to expand even on a variable assignment. You are right, the expansion was taking place in my echo statement when I did not have quotes around $files. Ok. I guess I need to stick to doing it as a list in zsh emulation mode. Thank you for clarifying that. -- 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