BASH: how to define an array as environment variable before calling a bash script -


in bash, can do

myvar="somevalue" ./myscript.sh 

and variable myvar defined when running myscript.sh.

my questions is: can same arrays? unfortunately, neither of following works.

myarr=( 1 2 ) ./myscript.sh myarr[0]=1 myarr[1]=2 ./myscript.sh declare -a myarr=( 1 2 ) ./myscript.sh 

incredibility weird.... have never seen before.

it looks array not passed subshell. 1 way around source script instead of executing it:

declare -a myarr=( 1 2 ); . ./myscript.sh 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -