[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: V+=1 doesn't work if V is a reference to an integer array element
From: |
felix |
Subject: |
Re: V+=1 doesn't work if V is a reference to an integer array element |
Date: |
Fri, 15 Jan 2021 17:50:24 +0100 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
This seem linked:
$ f() {
local -a a=('' 'foo');
local -n b=a[1];
echo $b;
b+=\ bar;
echo $b;
declare -p a;
}
$ f
foo
foo bar
declare -a a=([0]="" [1]="foo bar")
Ok, fine!
$ bash <(declare -f f | sed '1,2d; $s/.*/echo $BASH_VERSION/;
s/local /declare /;')
foo
fooa[1] bar
declare -a a=([0]="" [1]="fooa[1] bar")
5.1.4(1)-release
There is something!
New try:
$ f() {
local -ai a=(0 12);
local -n b=a[1];
echo $b;
b+=4;
echo $b;
declare -p a;
}
$ f
12
16
declare -ai a=([0]="0" [1]="16")
Seem good!
$ bash <(declare -f f |
sed '1,2d;$s/.*/echo $BASH_VERSION/;s/local /declare /;')
12
/dev/fd/63: line 4: a[1]4: syntax error in expression (error token is "4")
12
declare -ai a=([0]="0" [1]="12")
5.1.4(1)-release
--
Félix Hauri - <felix@f-hauri.ch> - http://www.f-hauri.ch
- Re: V+=1 doesn't work if V is a reference to an integer array element, (continued)
Re: V+=1 doesn't work if V is a reference to an integer array element, Ilkka Virta, 2021/01/13
Re: V+=1 doesn't work if V is a reference to an integer array element, Oğuz, 2021/01/13
Re: V+=1 doesn't work if V is a reference to an integer array element, Chet Ramey, 2021/01/13
- Re: V+=1 doesn't work if V is a reference to an integer array element,
felix <=