cc: piochjennifer at googlemail.com
Subject: Re: [ksh93-integration-discuss] Shell globs
--------

> I know you can use globs in shell scripts, but how do I control when
> the globbing is done?
> 
> For instance
> 
> pjfer at fragr:~:$ ls foo*
> foo1  foo2  foo3
> pjfer at fragr:~:$ a=foo*
> pjfer at fragr:~:$ echo $a
> foo1 foo2 foo3
> pjfer at fragr:~:$ echo "$a"
> foo*
> 
> How do I get variable a to contain the expanded list of files, rather
> than the glob itself?
> 
> One workaround I've found is to use ls to do it, but this seems very ugly
> a=`ls foo*`
> 
> Presumably I could use a subshell to expand the variable, but I can't
> get the syntax right.
> 
> Jenny
> -- 
> Jennifer Pioch, Uni Frankfurt

globbing is only done on command line arguments and on for or select lists.
Also, only done if noglob is not enabled.

There are a few ways you can do this.  Here are two.

var=$(IFS= print -r -- foo*)

set -- foo*
var=$*

David Korn
dgk at research.att.com

Reply via email to