bash - 无法在 UpStart 中声明数组,但可以在 bash 中声明

标签 bash ubuntu sh upstart

这是我遇到的问题的一个示例 - 尝试在 Upstart 中声明一个数组。我可以在 bash 提示符下运行 declare 行,但是当通过 upstart 脚本完成时 - 它会静默失败。

description "bla"
author "yea"
start on runlevel [2345]
script
    echo "yo" >> /var/log/arr.log 2>&1
    declare -a MYARR=("1,2" "3,4")

    echo "stuff"
end script

我在 ubuntu 14.04 上这样做

谢谢!

最佳答案

脚本代码将使用/bin/sh 执行。数组在纯 bourne shell 中不起作用。

看看How to use array in sh shell .

关于bash - 无法在 UpStart 中声明数组,但可以在 bash 中声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28912184/

相关文章:

bash - 使用 rsync 或 scp 在多个级别或 SSH 跃点上复制文件

Ubuntu下的shell ps命令

json - 将 IPv4 地址列表格式化\n 为 json

linux - 每次/bin/sh 被调用时你能运行一个脚本吗?

bash - 迭代数组名称的数组,将每个名称扩展为其成员

linux - noob - 语法错误 : redirection unexpected

linux - <br>如何在nagios中安装nagios check_procs插件</br>

mysql - 将sqlite文件转换成mysql

bash - 从 golang 代码重新加载或获取/etc/enviornment 文件

android - 如何在android中使用unix命令 'cat'连接sd卡中的两个视频文件?