1 /* logname -- print user's login name
2 Copyright (C) 1990-2024 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 3 of the License, or
7 (at your option) any later version.
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, see <https://www.gnu.org/licenses/>. */
19 #include <sys/types.h>
22 #include "long-options.h"
25 /* The official name of this program (e.g., no 'g' prefix). */
26 #define PROGRAM_NAME "logname"
28 #define AUTHORS proper_name ("FIXME: unknown")
33 if (status
!= EXIT_SUCCESS
)
37 printf (_("Usage: %s [OPTION]\n"), program_name
);
39 Print the user's login name.\n\
42 fputs (HELP_OPTION_DESCRIPTION
, stdout
);
43 fputs (VERSION_OPTION_DESCRIPTION
, stdout
);
44 emit_ancillary_info (PROGRAM_NAME
);
50 main (int argc
, char **argv
)
54 initialize_main (&argc
, &argv
);
55 set_program_name (argv
[0]);
56 setlocale (LC_ALL
, "");
57 bindtextdomain (PACKAGE
, LOCALEDIR
);
60 atexit (close_stdout
);
62 parse_gnu_standard_options_only (argc
, argv
, PROGRAM_NAME
, PACKAGE_NAME
,
63 Version
, true, usage
, AUTHORS
,
64 (char const *) nullptr);
68 error (0, 0, _("extra operand %s"), quote (argv
[optind
]));
72 /* POSIX requires using getlogin (or equivalent code) and prohibits
73 using a fallback technique. */
76 error (EXIT_FAILURE
, 0, _("no login name"));