]> git.ipfire.org Git - thirdparty/util-linux.git/blobdiff - login-utils/chfn.c
libblkid: check status for the current CDROM slot
[thirdparty/util-linux.git] / login-utils / chfn.c
index 7d14e7b4cfe59992c409ded8055ba44be7ea87a5..b7395552bba90578fc74bf704f9b0d263ac6d30d 100644 (file)
@@ -106,7 +106,7 @@ static void __attribute__((__noreturn__)) usage(void)
        fputs(USAGE_SEPARATOR, fp);
        printf( " -u, --help                   %s\n", USAGE_OPTSTR_HELP);
        printf( " -v, --version                %s\n", USAGE_OPTSTR_VERSION);
-       fprintf(fp, USAGE_MAN_TAIL("chfn(1)"));
+       printf(USAGE_MAN_TAIL("chfn(1)"));
        exit(EXIT_SUCCESS);
 }
 
@@ -176,8 +176,7 @@ static void parse_argv(struct chfn_control *ctl, int argc, char **argv)
                        status += check_gecos_string(_("Home Phone"), optarg);
                        break;
                case 'v':
-                       printf(UTIL_LINUX_VERSION);
-                       exit(EXIT_SUCCESS);
+                       print_version(EXIT_SUCCESS);
                case 'u':
                        usage();
                default:
@@ -377,7 +376,7 @@ static int save_new_data(struct chfn_control *ctl)
                        ctl->newf.other);
 
        /* remove trailing empty fields (but not subfields of ctl->newf.other) */
-       if (!ctl->newf.other) {
+       if (!ctl->newf.other || !*ctl->newf.other) {
                while (len > 0 && gecos[len - 1] == ',')
                        len--;
                gecos[len] = 0;
@@ -412,7 +411,8 @@ int main(int argc, char **argv)
        setlocale(LC_ALL, "");  /* both for messages and for iscntrl() below */
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
-       atexit(close_stdout);
+       close_stdout_atexit();
+
        uid = getuid();
 
        /* check /etc/login.defs CHFN_RESTRICT */