Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

shell question on exporting arrays

SOLVED
Go to solution
Highlighted
c_51
Trusted Contributor

shell question on exporting arrays

here is the set up

set -A ab 1 2 3
export ab
typeset -x | grep ^ab

file1:
print ${ab[@]}

file2:
#!/usr/bin/ksh
print ${ab[@]}

the question is, why is the output from
the two files different

and how can I get file2's output to look like file1's
4 REPLIES
c_51
Trusted Contributor

Re: shell question on exporting arrays

a little more information

I'm using the ksh shell for all of this and
/usr/bin/ksh ./file1 gives the same output
as file2 also.
Sridhar Bhaskarla
Honored Contributor
Solution

Re: shell question on exporting arrays

Hi,

From the man page of "ksh".

//
The export built-in command does not handle arrays properly. Only the
first element of an array is exported to the environment.//

Either you have to run file2 with a . (like . ./file2) or declare your arrays within file2 or put the array in a file (say arrays.rc and call it from file2 like . /whereever/arrays.rc)

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
c_51
Trusted Contributor

Re: shell question on exporting arrays

I figured as much.

thanks
c_51
Trusted Contributor

Re: shell question on exporting arrays

see previous reply