That is not exactly my code. You didn't even spell /etc/passwd right.
You might want to look at mimetool again. But anyway, remember that a passwd file entry is data separated by colons, like this...
field1:field2:field3
I wanted those field in an array. So i want to break the fields off one by one in a loop. I need to loop as long as there is at least two fields left. So I test for "*:*". Lets say there are only 3 fields as i show above. At first pwentry is "field1:field2:field3" and index is 0. So that line 4 sets
pwfield[0]=field1
and line 5 sets
pwentry="field2:field3"
This still matched the pattern *:* so we do the loop again and this time pwentry=field3. Now we don't match *:* anymore so we get out. Line 7 picks up that last field. In line 9 I am removing any comma and anything following the comma. That is because the gcos field is comma separated and I want the first sub-field.
That ${variable##pattern} and ${variable%%pattern} stuff has been discussed lots of times, use our search function. Or read "man ksh", it's there too.