gpt4 book ai didi

arrays - 在 bash 脚本中导出数组

转载 作者:行者123 更新时间:2023-12-02 04:29:11 25 4
gpt4 key购买 nike

我无法将数组从 bash 脚本导出到另一个 bash 脚本,如下所示:

export myArray[0]="Hello"
export myArray[1]="World"

当我这样写时,没有问题:
export myArray=("Hello" "World")

出于多种原因,我需要将数组初始化为多行。你有什么解决办法吗?

最佳答案

Array variables may not (yet) be exported.



来自 ubuntu 10.04 下 bash 版本 4.1.5 的联机帮助页。

Chet Ramey(截至 2011 年的当前 bash 维护者)的以下声明可能是关于此“错误”的最官方文档:

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

关于arrays - 在 bash 脚本中导出数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50650491/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com