1 /* logname -- print user's login name
2 Copyright (C) 1990-1997, 1999-2005 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
20 #include <sys/types.h>
25 #include "long-options.h"
28 /* The official name of this program (e.g., no `g' prefix). */
29 #define PROGRAM_NAME "logname"
31 #define AUTHORS "FIXME: unknown"
33 /* The name this program was run with. */
39 if (status != EXIT_SUCCESS)
40 fprintf (stderr, _("Try `%s --help' for more information.\n"),
44 printf (_("Usage: %s [OPTION]\n"), program_name);
46 Print the name of the current user.\n\
49 fputs (HELP_OPTION_DESCRIPTION, stdout);
50 fputs (VERSION_OPTION_DESCRIPTION, stdout);
51 printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
57 main (int argc, char **argv)
61 initialize_main (&argc, &argv);
62 program_name = argv[0];
63 setlocale (LC_ALL, "");
64 bindtextdomain (PACKAGE, LOCALEDIR);
67 atexit (close_stdout);
69 parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
70 usage, AUTHORS, (char const *) NULL);
71 if (getopt_long (argc, argv, "", NULL, NULL) != -1)
76 error (0, 0, _("extra operand %s"), quote (argv[optind]));
80 /* POSIX requires using getlogin (or equivalent code). */
87 /* POSIX prohibits using a fallback technique. */
89 error (0, 0, _("no login name"));