I am working with: s3-bash, when I run it in my local environment (OS X 10.10.1) I don't have any problems, when I try to run it on a ubuntu server 14.04.1 I get the following error:
./s3-common-functions: line 66: temporaryFiles: unbound variable
./s3-common-functions: line 85: temporaryFiles: unbound variable
I've looked at the s3-common-functions script and the variable looks to be initialized properly (as an array):
# Globals
declare -a temporaryFiles
But there is a note in the comment, and I'm sure if it's related:
# Do not use this from directly. Due to a bug in bash, array assignments do not work when the function is used with command substitution
function createTemporaryFile
{
local temporaryFile="$(mktemp "$temporaryDirectory/$$.$1.XXXXXXXX")" || printErrorHelpAndExit "Environment Error: Could not create a temporary file. Please check you /tmp folder permissions allow files and folders to be created and disc space." $invalidEnvironmentExitCode
local length="${#temporaryFiles[@]}"
temporaryFiles[$length]="$temporaryFile"
}
unbound variableis what you get when usingset -u. Do you have that set in whatever environment you are running the script?foo=$(bar)runsbarin a subshell, so of course assignments done inside that subshell don't propagate to the parent shell.temporaryFiles+=( "$temporaryFile" )... though, of course, that doesn't change anything about propagation of variables from subshells to parents).set -uis called a few lines above as well asset -e, I'm not an expert in bash so I'm not sure the effect, but I shouldn't have to set any env. variables to run the script (I don't believe). It also appears to fail when reading the array lengthlocal length="${#temporaryFiles[@]}"&length="${#temporaryFiles[@]}"