Posted by: Wildan Maulana | July 14, 2007

Dimensional Array in ash

here is no direct support for arrays in ash…you have to use eval,
setvar, etc:

– To set varibles:
for index in 1 2 3 ; do
setvar myvar$index “Index: $index”
eval myothervar$index=\”Index: $index\”
done

– To use variables:
for index in 1 2 3 ; do
eval echo $myvar$index
done

index=2
eval assign=”$myvar$index”
echo $assign

NOTES:
——
– Be careful with quoting when using eval!

– Bash doesn’t have the setvar command, so you might want to stick with
using eval


Charles Steinkuehler


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: