Like in a title, I've declared bunch of variables and a function. And when I pass them through a function I've got what I expected. But running same code through parallel didn't... How to fix it?
#!/bin/bash
declare -xA MAP # export associative array
declare -x str="ing" # export variable
MAP[bar]="baz"
MAP[bar2]="baz2"
foo() {
echo "$@"
echo "variable: ${str}"
echo "map: ${MAP[@]}"
}
export -f foo
foo "call function directly:"
call function directly:
variable: ing
map: baz2 baz
parallel foo ::: "call function through parallel" ::: 1 2 3
call function through parallel 1
variable: ing
map:
call function through parallel 2
variable: ing
map:
call function through parallel 3
variable: ing
map:
edit after comments
It looks that accepted answer for this question is: There isn't really a good way to encode an array variable into the environment.
Which is a bit sad... ;)