在导出bash脚本数组 [英] Exporting an array in bash script
问题描述
我无法从一个bash脚本输出数组这样的另一个bash脚本:
出口myArray的[0] =你好
出口myArray的[1] =世界
当我写这样没有问题:
出口myArray的=(你好,世界)
有关几个原因,我需要我的数组初始化成多行。你有什么解决办法吗?
数组变量可能(还)没有出口。
块引用>从bash的版本4.1.5手册页ubuntu下10.04。
从切特雷米(当前bash的维护者2011年)下面的语句大概是这个错误最官方文档:
是不是真的有一个很好的方式连接code数组变量到环境中。
块引用><一个href=\"http://www.mail-archive.com/bug-bash@gnu.org/msg01774.html\">http://www.mail-archive.com/bug-bash@gnu.org/msg01774.html
I can not export an array from a bash script to another bash script like this:
export myArray[0]="Hello" export myArray[1]="World"
When I write like this there are no problem:
export myArray=("Hello" "World")
For several reasons I need to initialize my array into multiple lines. Do you have any solution?
解决方案Array variables may not (yet) be exported.
From the manpage of bash version 4.1.5 under ubuntu 10.04.
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.
http://www.mail-archive.com/bug-bash@gnu.org/msg01774.html
这篇关于在导出bash脚本数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!