Current Array Export Situation 10/2021
Array export is not fully implemented yet. You can clone the source code with command git clone https://git.savannah.gnu.org/git/bash.git ~/bash-src. Look into the bash source ~/bash-src/config-top.h for the commented line 154:
/* Define to 1 if you want to be able to export indexed arrays to processes
using the foo=([0]=one [1]=two) and so on */
/* #define ARRAY_EXPORT 1 */
and furthermore the code section in ~/bash-src/variables.c at line 429 which says
#if defined (ARRAY_VARS)
# if ARRAY_EXPORT
/* Array variables may not yet be exported. */
if (*string == '(' && string[1] == '[' && string[strlen (string) - 1] == ')')
{
string_length = 1;
temp_string = extract_array_assignment_list (string, &string_length);
temp_var = assign_array_from_string (name, temp_string, 0);
FREE (temp_string);
VSETATTR (temp_var, (att_exported | att_imported));
array_needs_making = 1;
}
else
# endif /* ARRAY_EXPORT */
#endif
so basically some more work has to be put into this issue.
Workaround
Meanwhile you can export the BASH_ENV variable which can point to an environment script. I put mine into /etc/bash.environment and declare system-wide arrays there. Your ~/.bashrc could contain something like export BASH_ENV="~/.bash.environment", now every bash process executed by the current user will source this file.
As @they mentioned below an according ~/.bashrc configuration to take effect on interactive AND noninteractive shells is needed:
[ -r "~/.bash.environment" ] \
&& source "~/.bash.environment" \
&& export BASH_ENV="~/.bash.environment"
And finally your environment:
# ~/.bash.environment
export HELLO="ee"
export HELLOO=(aaa bbbb ccc)
Non-persistent Workaround
A non-persistent solution for passing arrays quick and dirty could look like so, that you assign the named pipe created by process substitution <() to BASH_ENV environment variable:
BASH_ENV=<(declare -p HELLO HELLOO) your_script.sh
Best wishes