Hi,
I have a shell script which reads a file and checks for the attributes and its values in the file.The values are comma/semicolon separated so a splitting mechanism is used.Here is the relevant part of the script -
--------------------------------------------------------------
# Get a count of how many elements are in each row and keep track of the max
i=1
while [ -n "${!i}" ]; do
local val="${!i}"
eval "$val=\"${!val};\""
eval "let __tally_$val=0"
#SK001 Start
#Added one more validation in while statement for length validation
#while [ "${!val}" != "" ]; do
while [ "${!val}" != "" ] && [ "${!val}" != ";" ]; do
#SK001 End
eval "$val=\"${!val#*[,;]}\""
eval "let __tally_$val++"
done
local count
eval "count=\$__tally_$val"
echo "<$count>"
if [ "$count" -gt "$max" ]; then
max=$count
fi
let i++
done
----------------------------------------------------------------
I have made bold the line which does the splitting part.An example of an attribute value is - CFG_DISKLETTERS = "a,b;c,d"
If it is the above,the number of diskletters is populated as 4. But if the attribute value is something like this - CFG_DISKLETTERs = "a,b;c,,,d"
then even the commas are counted and number of values is populated as 6.
I am not able to understand the splitting mechanism being used so I am not able to correct the problem.Please help.