ksh array updated by multiple scripts

Hello!

Is it possible to update an array created in a ksh script by a child script that was spawned by the parent?

So, if I have...

#!/bin/ksh

set -A myArray "Zero" "One" "Two"
echo "0: ${myArray[0]}"
echo "1: ${myArray[1]}"
echo "2: ${myArray[2]}"

./second_script.ksh ${myArray
[*]}
echo "All: ${myArray[@]}"

exit 0

Then in the child script, add elements "Three" "Four" "Five" to the array. Then print or whatever, the array from the parent script?

If not, is there a way to do something like this?

Thanks in advance.

If you create a new shell, variables cannot travel from it to the old shell.

One solution would be to source the script instead of executing it, which would run it in the same shell:

. ./scriptname

The use of 'exit' is one potential pitfall, which would cause it to quit completely instead of returning, if you use exit you must use return instead in the sourced script.

Another solution would be to have the script print the values, for you to read into the old shell.

Thanks. I'm just going to use a temp file. that would be the most straight forward.