Tizen 2.0 Release
[external/tizen-coreutils.git] / src / true.c
1 /* Exit with a status code indicating success.
2    Copyright (C) 1999-2003, 2005 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 2, or (at your option)
7    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, write to the Free Software Foundation,
16    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
17
18 #include <config.h>
19 #include <stdio.h>
20 #include <sys/types.h>
21 #include "system.h"
22
23 /* Act like "true" by default; false.c overrides this.  */
24 #ifndef EXIT_STATUS
25 # define EXIT_STATUS EXIT_SUCCESS
26 #endif
27
28 #if EXIT_STATUS == EXIT_SUCCESS
29 # define PROGRAM_NAME "true"
30 #else
31 # define PROGRAM_NAME "false"
32 #endif
33
34 #define AUTHORS "Jim Meyering"
35
36 /* The name this program was run with. */
37 char *program_name;
38
39 void
40 usage (int status)
41 {
42   printf (_("\
43 Usage: %s [ignored command line arguments]\n\
44   or:  %s OPTION\n\
45 "),
46           program_name, program_name);
47   printf ("%s\n\n",
48           _(EXIT_STATUS == EXIT_SUCCESS
49             ? "Exit with a status code indicating success."
50             : "Exit with a status code indicating failure."));
51   fputs (HELP_OPTION_DESCRIPTION, stdout);
52   fputs (VERSION_OPTION_DESCRIPTION, stdout);
53   printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
54   printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
55   exit (status);
56 }
57
58 int
59 main (int argc, char **argv)
60 {
61   initialize_main (&argc, &argv);
62   program_name = argv[0];
63   setlocale (LC_ALL, "");
64   bindtextdomain (PACKAGE, LOCALEDIR);
65   textdomain (PACKAGE);
66
67   atexit (close_stdout);
68
69   /* Recognize --help or --version only if it's the only command-line
70      argument.  */
71   if (argc == 2)
72     {
73       if (STREQ (argv[1], "--help"))
74         usage (EXIT_STATUS);
75
76       if (STREQ (argv[1], "--version"))
77         version_etc (stdout, PROGRAM_NAME, GNU_PACKAGE, VERSION, AUTHORS,
78                      (char *) NULL);
79     }
80
81   exit (EXIT_STATUS);
82 }