Good day list -
There seems to be no way of testing if an array variable is associative or not ,
yet attempting to make associative assigments to a normal array results in a
syntax error .
I have something like:
declare -xr TYPE_ARRAY=0 TYPE_ASSOC=1
function f()
{ declare -n an_arra
On Fri, Aug 29, 2014 at 03:07:40PM +0100, Jason Vas Dias wrote:
> There seems to be no way of testing if an array variable is associative or not
$ unset a b; declare -A a; a[1]=foo; b=(an array); declare -p a b
declare -A a='([1]="foo" )'
declare -a b='([0]="an" [1]="array")'
Sorry, mailer sent previous mail before I was ready. Reposting.
Good day list -
There seems to be no way of testing if an array variable is associative or not ,
I have something like:
declare -xr TYPE_ARRAY=0 TYPE_ASSOC=1
function f()
{ declare -n an_array=$1;
local type=$2;
On 8/29/14, 10:21 AM, Jason Vas Dias wrote:
> Sorry, mailer sent previous mail before I was ready. Reposting.
>
> Good day list -
>
> There seems to be no way of testing if an array variable is associative or
> not ,
>
> I have something like:
>
> declare -xr TYPE_ARRAY=0 TYPE_ASSOC=1
>
Actually, this appears to be a bit more involved.
What I was actually trying to work out was
the bash error that occurs with :
$( function f()
{
local an_array=$1;
local value='1.0';
local v=value;
local ev='['"'"'value'"'"']='"'""${!v}""'";
eval ${an_array}='('"$ev"')';
}
de
On Fri, Aug 29, 2014 at 04:45:30PM +0100, Jason Vas Dias wrote:
> local value='1.0';
> The end result expression being evaluated:
> ++ my_array=(['value']='1.0')
> should never involve an arithmetic expression,
> and should be valid regardless if the array is
> associative or not .
Your i
Sorry - forget the bit about indirect expansion - the error only
occurs if the array is originally declared not associative :
$ ( function f() { local an_array=$1; local value='1.0';
local ev='['"'"'value'"'"']='"'""$value""'"; eval
${an_array}='('"$ev"')'; }; declare -a my_array; s
On 8/29/14, 11:45 AM, Jason Vas Dias wrote:
> Nor does the error happen if indirect expansion is not used:
Just to head off a potential question. This is not the same as the first
example, since my_array is declared as an associative array.
> $ ( function f() { local an_array=$1; loc
On Fri, Aug 29, 2014 at 05:19:03PM +0100, Jason Vas Dias wrote:
> Aha! Yes, that was it . Thank you!
> I wouldn't have expected expansion to occur for a name in single quotes.
>
> I still think it would be nice to have the ability to tell if an array has
> been
> declared associative or not. Wha
2014-08-27 15:35:06 -0400, Chet Ramey:
> On 8/27/14, 3:20 PM, Stephane Chazelas wrote:
>
> > However, one could imagine using bash's read to get data off a
> > tty device not in canonical mode (a serial device used as just a
> > serial device), or any other non-terminal character device for
> > th
The following is my test scripts and their output.
They are very similar, and I do not think they should result in
different output.
The output I expected from all of them is:
v1
v2
But as you can see, only 1 in the following 4 cases does it meet my
expectation. In the other 3 cases, the nameref
On Sat, Aug 30, 2014 at 11:19 AM, lolilolicon wrote:
> The following is my test scripts and their output.
> They are very similar, and I do not think they should result in
> different output.
> The output I expected from all of them is:
>
> v1
> v2
>
> But as you can see, only 1 in the following 4
On Sat, Aug 30, 2014 at 11:39 AM, lolilolicon wrote:
>
> As you see, once ref is assigned explicitly, or indeed, is assigned for
> a second time, its nameref attribute is lost.
OK, here is the minimum script that demonstrates the bug:
=== script ===
#!/bin/bash
declare var="hello world"
declare
On Sat, Aug 30, 2014 at 11:51 AM, lolilolicon wrote:
> On Sat, Aug 30, 2014 at 11:39 AM, lolilolicon wrote:
>>
>> As you see, once ref is assigned explicitly, or indeed, is assigned for
>> a second time, its nameref attribute is lost.
>
> OK, here is the minimum script that demonstrates the bug:
14 matches
Mail list logo