Some explanations about the script
-F "="
Set the internal awk variable FS to "=".,this specify the field separator value.
NF >= 2 { . . . . }
Select lines with two or more fields (in the form variable=value) and specify the code to execute for those lines.
variable = $1 ; value = $2
Get the variable name an it's value (fields delimited by FS="=")
if (value ~ /^\(.*\)[:space:]*$/) { ... }
Test if the value is an array definition
value ~ /.../ : value match the regular expression
^ : start of string
\(.*\) : characters between parenthesis
[:space:]* : spaces (space or tab)
$ : end of string
sub(/^\(/,"",value)
Remove ( at start of string in variable value
sub(/\)[:space:]*$/,"",value")
Remove last ) and optionals spaces at end of string in variable value.
Now, value contains elements of array delimited by commas
nbv = split(value, values, ",")
The elements of array are stored in the array values (elements delimited by "," in value).
The number of elements is stored in the variable nbv.
for (i=1; i<=nbv; i++) print variable "_" i "=" values[i];
For each element of the array a variable assignment is created in the form :
variable_n=value_n
else { print variable "=" value }
The else state for 'not an array definition'.
The variable assignment is printed in the form :
variable=value
(same as input without optional ending spaces).
The global result of the awk script is a list of variable assignments that are evaluated by the 'eval' command to define script variables.
You need to determine how many values are supplied for a variable (array definition). I propose you to define an extra variable which contains this count
(for example admin_role_count=3).
Add the following statement in the awk script :
for (i=1; i<=nbv; i++)
print variable "_" i "=" values[i];
print variable "_count=" nbv;
Jean-Pierre.