when you create the user it does place name in the /etc/group file, but then if your script also uses the -G option to add to other groups, it copies the /etc/group file to /etc/group- and then writes the new group entries. But it firsts copies the /etc/group- file, which is a template with no entries in the users group, back to /etc/group so the new user is now NOT listed in the copied /etc/group file and then adds the additional group entries. Confusing???
What needs done in the adduser script is to copy the /etc/group file AFTER user has been created and they are listed in the users group to /etc/group- so that when you add addtional group entries with the -G option, it does it thing of copying the template /etc/group- to /etc/group, but this time user is listed in the users section as well as any addtional group because you trick the system when it does its copy back. It thinks it is copying the blank template /etc/group- file to /etc/group, but etc/group- at that point is really a copy of the etc/group file.... whew!!!