加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

arrays – 在bash脚本中导出数组

发布时间:2020-12-15 20:02:42 所属栏目:安全 来源:网络整理
导读:我不能将一个数组从一个bash脚本导出到另一个bash脚本,像这样: export myArray[0]="Hello"export myArray[1]="World" 当我写这样没有问题: export myArray=("Hello" "World") 由于几个原因,我需要将我的数组初始化为多行。你有什么解决方案吗? Array va
我不能将一个数组从一个bash脚本导出到另一个bash脚本,像这样:
export myArray[0]="Hello"
export myArray[1]="World"

当我写这样没有问题:

export myArray=("Hello" "World")

由于几个原因,我需要将我的数组初始化为多行。你有什么解决方案吗?

Array variables may not (yet) be exported.

从bash版本4.1.5的manpage在ubuntu 10.04下。

下面的语句从Chet Ramey(当前bash维护者2011年)可能是关于这个“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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读