我不能将数组从bash脚本导出到另一个bash脚本,如下所示:
I can not export an array from a bash script to another bash script like this:
export myArray[0]="Hello" export myArray[1]="World"当我这样写没有问题:
export myArray=("Hello" "World")由于几个原因,我需要将我的数组初始化为多行。你有什么解决方案吗?
For several reasons I need to initialize my array into multiple lines. Do you have any solution?
推荐答案
数组变量可能还没有被导出。 p>
Array variables may not (yet) be exported.
从ubuntu 10.04下的bash版本4.1.5的联机帮助页。
From the manpage of bash version 4.1.5 under ubuntu 10.04.
以下来自Chet Ramey(目前的bash维护者截至2011年)的声明可能是关于这个bug的最正式的文档:
The following statement from Chet Ramey (current bash maintainer as of 2011) is probably the most official documentation about this "bug":
真的是将数组变量编码到环境中的好方法。
There isn't really a good way to encode an array variable into the environment.
www.mail-archive/bug-bash@gnu/msg01774.html
更多推荐
在bash脚本中导出数组
发布评论