- char name[BUFSIZ], *p;
-
- if (argc > 1) {
- fprintf (stderr, "usage: %s\n", argv[0]);
- }
-
- pwd = getpwuid(getuid());
-
- if (! pwd) {
- fprintf(stderr, "Unable to retrieve user info for "
- "userid %ld\n", (long) getuid());
- exit(1);
+ char buf[BUFSIZ], *p;
+
+ if (argc < 2) {
+ pwd = getpwuid(getuid());
+
+ if (! pwd) {
+ fprintf(stderr, "Unable to retrieve user info for "
+ "userid %ld\n", (long) getuid());
+ exit(1);
+ }
+
+ strncpy(buf, pwd->pw_gecos, sizeof(buf));
+ buf[sizeof(buf) - 1] = '\0';
+ } else if (argc == 2) {
+ strncpy(buf, argv[1], sizeof(buf));
+ } else if (argc > 2) {
+ fprintf (stderr, "usage: %s [name]\n", argv[0]);
+ return 1;