2014-12-03 23 views
5
Fedora kodu davranır 20.

vs '-A x ilan 'beyan -A X =()'

aşağıdaki iki adet tarafından çalıştırılır 4.2.53 (1) -salınımı, kullanıyorum

farklı olarak, neden kimse söyleyebilir? Teşekkürler.

[hidden]$ unset x; declare -p x; function f() { declare -A -g x; x[10]=100; }; f; declare -p x; 
-bash: declare: x: not found 
declare -A x='([10]="100")' 
[hidden]$ unset x; declare -p x; function f() { declare -A -g x=(); x[10]=100; }; f; declare -p x; 
-bash: declare: x: not found 
declare -A x='()' 

cevap

5

Bu, 4.0-4.2'deki bir hataydı. O fixed in 4.3 oldu: İşte

ddd. Fixed several bugs that caused `declare -g' to not set the right global 
    variables or to misbehave when declaring global indexed arrays. 

onlar aynı şekilde davranır 4.3, üzerinde sonucudur:

$ echo $BASH_VERSION 
4.3.11(1)-release 

$ unset x; declare -p x; function f() { declare -A -g x; x[10]=100; }; f; declare -p x; 
bash: declare: x: not found 
declare -A x='([10]="100")' 

$ unset x; declare -p x; function f() { declare -A -g x=(); x[10]=100; }; f; declare -p x; 
bash: declare: x: not found 
declare -A x='([10]="100")' 
İlgili konular