Line data Source code
1 : /* Exit with a status code indicating success.
2 : Copyright (C) 1999-2003, 2005, 2007 Free Software Foundation, Inc.
3 :
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.
8 :
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.
13 :
14 : You should have received a copy of the GNU General Public License
15 : along with this program. If not, see <http://www.gnu.org/licenses/>. */
16 :
17 : #include <config.h>
18 : #include <stdio.h>
19 : #include <sys/types.h>
20 : #include "system.h"
21 :
22 : /* Act like "true" by default; false.c overrides this. */
23 : #ifndef EXIT_STATUS
24 : # define EXIT_STATUS EXIT_SUCCESS
25 : #endif
26 :
27 : #if EXIT_STATUS == EXIT_SUCCESS
28 : # define PROGRAM_NAME "true"
29 : #else
30 : # define PROGRAM_NAME "false"
31 : #endif
32 :
33 : #define AUTHORS "Jim Meyering"
34 :
35 : /* The name this program was run with. */
36 : char *program_name;
37 :
38 : void
39 1 : usage (int status)
40 : {
41 1 : printf (_("\
42 : Usage: %s [ignored command line arguments]\n\
43 : or: %s OPTION\n\
44 : "),
45 : program_name, program_name);
46 1 : printf ("%s\n\n",
47 : _(EXIT_STATUS == EXIT_SUCCESS
48 : ? "Exit with a status code indicating success."
49 : : "Exit with a status code indicating failure."));
50 1 : fputs (HELP_OPTION_DESCRIPTION, stdout);
51 1 : fputs (VERSION_OPTION_DESCRIPTION, stdout);
52 1 : printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
53 1 : emit_bug_reporting_address ();
54 1 : exit (status);
55 : }
56 :
57 : int
58 6 : main (int argc, char **argv)
59 : {
60 : initialize_main (&argc, &argv);
61 6 : program_name = argv[0];
62 6 : setlocale (LC_ALL, "");
63 : bindtextdomain (PACKAGE, LOCALEDIR);
64 : textdomain (PACKAGE);
65 :
66 6 : atexit (close_stdout);
67 :
68 : /* Recognize --help or --version only if it's the only command-line
69 : argument. */
70 6 : if (argc == 2)
71 : {
72 4 : if (STREQ (argv[1], "--help"))
73 1 : usage (EXIT_STATUS);
74 :
75 3 : if (STREQ (argv[1], "--version"))
76 1 : version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, VERSION, AUTHORS,
77 : (char *) NULL);
78 : }
79 :
80 5 : exit (EXIT_STATUS);
81 : }
|