在bash脚本中导出数组

编程入门 行业动态 更新时间:2024-10-28 02:34:32
本文介绍了在bash脚本中导出数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不能将数组从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脚本中导出数组

本文发布于:2023-10-29 08:40:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539232.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数组   脚本   bash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!