Exporting array variables prevents values from being set locally on bionic

As part of a Travis build, I’m running a relatively simple bash script downloaded from here and exporting several array variables. I have now realized that exporting array variables is not supported in bash, but the issue is that the exporting is also blocking the variables from being set locally for some reason. Although I source the script, the variables aren’t properly set. The whole setup works fine on xenial and MacOS (with recent bash downloaded from homebrew). I also checked that it works fine if I run the script locally in the same Docker container as the job is being run in on Travis (travisci/ci-ubuntu-1804:packer-1593521720-ca42795e). There seems to be something with the way Travis is wrapping these scripts when processing the configuration file that is causing this behavior. I know that I can simply not export the bash arrays, but am posting this for the benefit of others who may run into this and because it seems to be buggy behavior.

A recent build that demonstrates the behavior is here and the configuration is here. In the first job here running on bionic, I set the value of the variable COMMON_ARGS (a bash array) in the script here like so:

export COMMON_ARGS=(--no-prompt --verbosity ${VERBOSITY:-2} --tests main --enable-relocatable)

Afterwards, I echo it’s value here (along with the values of some other variables) like so:

echo "${COMMON_ARGS[@]}" "${ADD_ARGS[@]}" "${DBG_ARGS[@]}"

but the variables whose values were just set are now empty.

Hello @tkralphs,

It seems after a branch refactor this passes build, are you still having the same issue?

Hi @Montana, the build was never failing as a result of this issue, it just wasn’t building in the configuration I had specified because of the fact that the variables weren’t getting set properly. I have a workaround now, so I guess it’s not an issue for me, but I believe this is a bug and since it caused me a lot of headache before I figured out the workaround, I thought it would be useful to others to report it. It may also indicate some issue with the way Travis is processing the configuration file, which could have bigger implications, not sure. So for me, everything is currently OK.

1 Like

Hey @tkralphs,

Thanks for the update - if there’s anything else please post back and I’ll help you out!