bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash does filename expansion when assigning to array member in compo


From: Dan Douglas
Subject: Re: bash does filename expansion when assigning to array member in compound form
Date: Mon, 20 Aug 2012 16:12:19 -0500
User-agent: KMail/4.8.3 (Linux/3.4.6-pf+; KDE/4.8.3; x86_64; ; )

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.

Of course, In that shell in order to use "[n]="-style indexing each and every 
element needs to be specified that way explicitly. I like that Bash can just 
implicitly start counting at any index.
-- 
Dan Douglas



reply via email to

[Prev in Thread] Current Thread [Next in Thread]