[BusyBox-cvs] busybox/loginutils addgroup.c,1.8,1.9
Erik Andersen
andersen at codepoet.org
Thu Jan 9 18:53:56 UTC 2003
Update of /var/cvs/busybox/loginutils
In directory winder:/tmp/cvs-serv29662
Modified Files:
addgroup.c
Log Message:
Fix addgroup so it actually works
-Erik
Index: addgroup.c
===================================================================
RCS file: /var/cvs/busybox/loginutils/addgroup.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- addgroup.c 13 Dec 2002 22:02:12 -0000 1.8
+++ addgroup.c 9 Jan 2003 18:53:53 -0000 1.9
@@ -132,23 +132,33 @@
* ________________________________________________________________________ */
int addgroup_main(int argc, char **argv)
{
+ int opt;
char *group;
char *user;
gid_t gid = 0;
- if (argc < 2) {
- show_usage();
+ /* get remaining args */
+ while ((opt = getopt (argc, argv, "g:")) != -1) {
+ switch (opt) {
+ case 'g':
+ gid = strtol(optarg, NULL, 10);
+ break;
+ default:
+ show_usage();
+ break;
+ }
}
- if (strncmp(argv[1], "-g", 2) == 0) {
- gid = strtol(argv[2], NULL, 10);
- group = argv[2];
+ if (optind < argc) {
+ group = argv[optind];
+ optind++;
} else {
show_usage();
}
-
- if (argc == 4) {
- user = argv[3];
+
+ if (optind < argc) {
+ user = argv[optind];
+ optind++;
} else {
user = "";
}
More information about the busybox-cvs
mailing list