On 8/20/12 5:12 PM, Dan Douglas wrote:
> On Monday, August 20, 2012 07:44:51 PM Roman Rakus wrote:
>> And how would you achieve to fill array with all file names containing 
>> `[1]=' for example.
> 
> $ ls
> [1]=a  [1]=b
> $ ( typeset -a a=( \[1\]=* ); typeset -p a )
> typeset -a a=('[1]=a' '[1]=b')
> $ ( typeset -a a=( [1]=* ); typeset -p a )
> typeset -a a=([1]='*')
> $
> 
> In ksh93, by escaping. I think this is what most people would expect and 
> probably what Bash intended.

Then how about this: words inside a compound assignment statement that are
recognized as assignment statements ([1]=foo) are expanded like assignment
statements (no brace expansion, globbing, or word splitting).  Other words
undergo all the expansions.

That means you can do things like

[{0,1,2,3}]=foo

to set the first four elements to the same value, but things like

f='more than one word'

x=( [0]=$f )

will still only set the first element.  This sounds like what you're after.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/

Reply via email to