zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-users@sunsite.dk
Subject: Re: variable assignment in a script using globsubst
Date: Wed, 18 May 2005 10:49:10 +0100	[thread overview]
Message-ID: <17522.1116409750@csr.com> (raw)
In-Reply-To: Message from Vincent Stemen <zsh@hightek.org>  of "Tue, 17 May 2005 23:43:55 CDT." <20050518044354.GA96824@quark.hightek.org>

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 <pws@csr.com>                  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.

**********************************************************************


  parent reply	other threads:[~2005-05-18  9:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-18  4:43 Vincent Stemen
     [not found] ` <zsh@hightek.org>
2005-05-18  9:49   ` Peter Stephenson [this message]
2005-05-18 17:22     ` Vincent Stemen
2005-05-18 17:49   ` Peter Stephenson
2005-05-19 18:28     ` Vincent Stemen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17522.1116409750@csr.com \
    --to=pws@csr.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).