summaryrefslogtreecommitdiff
path: root/src/logname.c
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-04 17:13:50 +0300
commit71cd8e3a743046573744123777061b64881bf372 (patch)
tree82522befe647f4fff186a5630cad0cad33f8ef53 /src/logname.c
parentc18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff)
downloadcoreutils-upstream.tar.gz
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'src/logname.c')
-rw-r--r--src/logname.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/logname.c b/src/logname.c
index 6afa1b50..070c9017 100644
--- a/src/logname.c
+++ b/src/logname.c
@@ -1,5 +1,5 @@
/* logname -- print user's login name
- Copyright (C) 1990-2014 Free Software Foundation, Inc.
+ Copyright (C) 1990-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -43,7 +43,7 @@ Print the name of the current user.\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
fputs (VERSION_OPTION_DESCRIPTION, stdout);
- emit_ancillary_info ();
+ emit_ancillary_info (PROGRAM_NAME);
}
exit (status);
}
@@ -72,15 +72,12 @@ main (int argc, char **argv)
usage (EXIT_FAILURE);
}
- /* POSIX requires using getlogin (or equivalent code). */
+ /* POSIX requires using getlogin (or equivalent code) and prohibits
+ using a fallback technique. */
cp = getlogin ();
- if (cp)
- {
- puts (cp);
- exit (EXIT_SUCCESS);
- }
- /* POSIX prohibits using a fallback technique. */
+ if (! cp)
+ error (EXIT_FAILURE, 0, _("no login name"));
- error (0, 0, _("no login name"));
- exit (EXIT_FAILURE);
+ puts (cp);
+ return EXIT_SUCCESS;
}