* globbing in assignment @ 2012-05-23 6:18 Han Pingtian 2012-05-23 9:10 ` Peter Stephenson 0 siblings, 1 reply; 5+ messages in thread From: Han Pingtian @ 2012-05-23 6:18 UTC (permalink / raw) To: zsh-users Hello, I just notice filename globbing doesn't occur in my script, like v=* but it works in the interactive shell. Althoug I can make it work by "setop glob_assign" or use "v=(*)", but it looks like the behavior's diversity is a little strange. Any thoughts? Thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: globbing in assignment 2012-05-23 6:18 globbing in assignment Han Pingtian @ 2012-05-23 9:10 ` Peter Stephenson 2012-05-23 10:08 ` Han Pingtian 0 siblings, 1 reply; 5+ messages in thread From: Peter Stephenson @ 2012-05-23 9:10 UTC (permalink / raw) To: zsh-users On Wed, 23 May 2012 14:18:59 +0800 Han Pingtian <hanpt@linux.vnet.ibm.com> wrote: > I just notice filename globbing doesn't occur in my script, like > > v=* > > but it works in the interactive shell. Althoug I can make it work > by "setop glob_assign" or use "v=(*)", but it looks like the behavior's > diversity is a little strange. > > Any thoughts? I would guess you don't have the option set in one case, but do in another. Try putting "setopt globassign" at the start of the script, which seems to do what I expect here. There's no explicit code to stop it working in scripts. -- Peter Stephenson <pws@csr.com> Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: globbing in assignment 2012-05-23 9:10 ` Peter Stephenson @ 2012-05-23 10:08 ` Han Pingtian 2012-05-23 10:30 ` Peter Stephenson 0 siblings, 1 reply; 5+ messages in thread From: Han Pingtian @ 2012-05-23 10:08 UTC (permalink / raw) To: zsh-users On Wed, May 23, 2012 at 10:10:43AM +0100, Peter Stephenson wrote: > On Wed, 23 May 2012 14:18:59 +0800 > Han Pingtian <hanpt@linux.vnet.ibm.com> wrote: > > I just notice filename globbing doesn't occur in my script, like > > > > v=* > > > > but it works in the interactive shell. Althoug I can make it work > > by "setop glob_assign" or use "v=(*)", but it looks like the behavior's > > diversity is a little strange. > > > > Any thoughts? > > I would guess you don't have the option set in one case, but do in > another. Try putting "setopt globassign" at the start of the script, > which seems to do what I expect here. There's no explicit code to stop > it working in scripts. Thanks for reply. I don't set globassign in the interactive shell but the globbing is working in assigment. And finally I find out it's "glob_subst" which also has the same effect of "glob_assign". Maybe something is wrong? Looks like ther > > -- > Peter Stephenson <pws@csr.com> Software Engineer > Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited > Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK > > > Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom > More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: globbing in assignment 2012-05-23 10:08 ` Han Pingtian @ 2012-05-23 10:30 ` Peter Stephenson 2012-05-24 1:59 ` Han Pingtian 0 siblings, 1 reply; 5+ messages in thread From: Peter Stephenson @ 2012-05-23 10:30 UTC (permalink / raw) To: zsh-users On Wed, 23 May 2012 18:08:46 +0800 Han Pingtian <hanpt@linux.vnet.ibm.com> wrote: > Thanks for reply. I don't set globassign in the interactive shell but > the globbing is working in assigment. And finally I find out it's > "glob_subst" which also has the same effect of "glob_assign". Ah, you're misunderstanding what's going on. GLOB_ASSIGN has the effect that v=* expands * at this point. The value of v contains all the files. GLOB_SUBST has the effect that a variable is expanded at the point where it's substituted. So without GLOB_ASSIGN, or equivalently quoting the value assigned to v, % v='*' % setopt globsubst % print $v <files> % unsetopt globsubt % print $v * -- Peter Stephenson <pws@csr.com> Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: globbing in assignment 2012-05-23 10:30 ` Peter Stephenson @ 2012-05-24 1:59 ` Han Pingtian 0 siblings, 0 replies; 5+ messages in thread From: Han Pingtian @ 2012-05-24 1:59 UTC (permalink / raw) To: zsh-users On Wed, May 23, 2012 at 11:30:56AM +0100, Peter Stephenson wrote: > On Wed, 23 May 2012 18:08:46 +0800 > Ah, you're misunderstanding what's going on. > > GLOB_ASSIGN has the effect that > > v=* > > expands * at this point. The value of v contains all the files. > > GLOB_SUBST has the effect that a variable is expanded at the point where > it's substituted. So without GLOB_ASSIGN, or equivalently quoting the > value assigned to v, > > % v='*' > % setopt globsubst > % print $v > <files> > % unsetopt globsubt > % print $v > * > Thanks. Now I got it. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-24 2:10 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-05-23 6:18 globbing in assignment Han Pingtian 2012-05-23 9:10 ` Peter Stephenson 2012-05-23 10:08 ` Han Pingtian 2012-05-23 10:30 ` Peter Stephenson 2012-05-24 1:59 ` Han Pingtian
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).