Array Element

This question is for someone that's more familiar with Array Element.

I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024?

 
param_array[counter]="$param_nam"
counter=$counter+1
#to avoid space issue in the param
eval real_value=\"param_value\"
param_array[counter]=\"$real_value\"
counter=$counter+1

When the parm_value is more than 750 we do lose parameter value and I need to find out if there is a workaround using array element since there is a limitation to it.

Our shell script is korn shell on AIX platform.

Thanks

My advice, for dealing with these limits, is "when in doubt -- don't". If you might exceed the maximum size of an array, don't use an array! Tweaking it into working "for now" without solving the limits problem anywhere else is a temporary solution at best.

These limits are heavily shell and system specific, not just the kind of shell but the branch (there are several 'kinds' of ksh) and version. Making a script which abuses these limits could strand it on your system.

There is also a tendency to use shell arrays as a hammer -- when all you have is a hammer, the world looks like a nail. In many cases these are suboptimal and never required arrays in the first place, there may be more appropriate solutions to whatever you're doing.

So please explain what you are doing -- and do NOT say "trying to make a bigger array"! What is this array holding? Why do you need it?

You could also use a conf file for all those entries....
Even if it looks as simple as this:

var1="param_name1"
var2="param_name2"
...

While just reading from such a file is very easy using IFS="=" and a while read , any kind of 'dynamic' reading of a certain variable might become more complex.

There is the option to save each entry into a single file.

I just had help to avoid shell injection with my scripts regarding conf file modification http://www.unix.com/shell-programming-and-scripting/253615-reading-writing-conf-file-suggestions-improvements.html.

Their function:

# List all variables (NOT values!)
tui-conf-get -l "FILE"

# Get value
tui-conf-get "FILE" "VAR"

# Set value
tui-conf-set "FILE" "VAR" "VAL"

Maybe they could be of help?

I'd like to start with that: in AIX "ksh" is a Korn Shell 88, "ksh93" is a Korn Shell 93. Because the two behave differently in this regard, which one do you use?

This is so for ksh88, not so for ksh93 and the workaround is to use a different algorithm. I agree with Corona688: whatever you do you probably do it in a wrong way anyway.

These two lines will either lead to syntax errors or not do what you expect them to do. Instead use one of the following:

(( counter = counter + 1 ))
(( counter += 1 ))

Yikes! My advice is to stay away from "eval" as long as possible. It is a perfect recipe to shoot yourself into foot.

My suggestion is to explain what you want to achieve (instead of trying to find loopholes to make possible a pseudosolution which is bad anyway) and we will find a way to do that - without workarounds and most probably without "eval".

I hope this helps.

bakunin