作者:lin悟_462 | 来源:互联网 | 2023-05-25 19:19
1> Etan Reisner..:
这里似乎有一个bash行为改变.
由kojiro发现:变化
HHHH.修复了导致`declare'和`test'查找已赋予属性但未赋值的变量的错误.这些变量没有设定.
$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ set -u
$ declare -a tF
$ echo "${#tF[@]}"
0
与
$ bash --version
GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ set -u
$ declare -a tF
$ echo "${#tF[@]}"
0
与
$ bash --version
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ set -u
$ declare -a tF
$ echo "${#tF[@]}"
-bash: tF: unbound variable
您可以使用declare -a tF=()
较新的bash版本来解决此问题.
$ declare -a tF=()
$ echo "${#tF[@]}"
0
在bash-4.2-release和bash-4.3-alpha之间进行了更改:[_hhhh.修复了导致"声明"和"测试"查找已赋予属性但未赋值的变量的错误.这些变量没有设置._](https://tiswww.case.edu/php/chet/bash/CHANGES) - (对不起txt不允许更精确的链接,但如果你愿意,你可以搜索确切的文本.)