Injecting variable containing arrays such as the below, fails on bash, zxh and other shells.
Attempting to use these imported variables fails like this:
Normally there are two categories of variables available in shell: shell variables and Environment variables, where shell variables can also be exported to become Environment variables.
However, when testing the output of five commands that can list variables, it seems that injected array variables falls into a third category, as the array variables are available as Environmental variables, but not as shell variables:
- `declare -p`, `declare -xp` and `set` lists no injected array variables
- `printenv` and `env` lists injected array variables, as individual entries.
I've implemented workaround, which may be integrated into the plugin, that can be used to fix the main issue. It's available as a gist on github:
Using this workaround, the output from my test injection above looks like this:
A warning may be needed when this happens!
When importing/declaring variables like this:
will result in an unintended overwriting of test, resulting in an shell array variable declared like this:
- test=(="string3" ="string2")