global: convert indentation-TABs to spaces
[coreutils.git] / src / true.c
blob66d1e01116a2dbb6017dc2394f59a03fa20ff79d
1 /* Exit with a status code indicating success.
2 Copyright (C) 1999-2003, 2005, 2007-2009 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 <http://www.gnu.org/licenses/>. */
17 #include <config.h>
18 #include <stdio.h>
19 #include <sys/types.h>
20 #include "system.h"
22 /* Act like "true" by default; false.c overrides this. */
23 #ifndef EXIT_STATUS
24 # define EXIT_STATUS EXIT_SUCCESS
25 #endif
27 #if EXIT_STATUS == EXIT_SUCCESS
28 # define PROGRAM_NAME "true"
29 #else
30 # define PROGRAM_NAME "false"
31 #endif
33 #define AUTHORS proper_name ("Jim Meyering")
35 void
36 usage (int status)
38 printf (_("\
39 Usage: %s [ignored command line arguments]\n\
40 or: %s OPTION\n\
41 "),
42 program_name, program_name);
43 printf ("%s\n\n",
44 _(EXIT_STATUS == EXIT_SUCCESS
45 ? N_("Exit with a status code indicating success.")
46 : N_("Exit with a status code indicating failure.")));
47 fputs (HELP_OPTION_DESCRIPTION, stdout);
48 fputs (VERSION_OPTION_DESCRIPTION, stdout);
49 printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
50 emit_bug_reporting_address ();
51 exit (status);
54 int
55 main (int argc, char **argv)
57 initialize_main (&argc, &argv);
58 set_program_name (argv[0]);
59 setlocale (LC_ALL, "");
60 bindtextdomain (PACKAGE, LOCALEDIR);
61 textdomain (PACKAGE);
63 atexit (close_stdout);
65 /* Recognize --help or --version only if it's the only command-line
66 argument. */
67 if (argc == 2)
69 if (STREQ (argv[1], "--help"))
70 usage (EXIT_STATUS);
72 if (STREQ (argv[1], "--version"))
73 version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
74 (char *) NULL);
77 exit (EXIT_STATUS);