Search code examples
bashubuntushupstart

Unable to declare an array in UpStart but can in bash


This is a sample of a problem I'm having - trying to declare an array in Upstart. I can run the declare line on the bash prompt but when done via an upstart script - it fails silently.

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

I'm doing this on ubuntu 14.04

Thanks!


Solution

  • Script code will be executed using /bin/sh. Arrays won't work in pure bourne shell.

    Take a look at How to use array in sh shell.