]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(usage): Use EXIT_SUCCESS, not 0, for clarity.
authorJim Meyering <jim@meyering.net>
Thu, 22 Jan 2004 20:44:15 +0000 (20:44 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 22 Jan 2004 20:44:15 +0000 (20:44 +0000)
(main): Use initialize_exit_failure rather than setting
exit_failure directly; this optimizes away redundant assignments.

(PRINTENV_FAILURE): New constant.
(main): Exit with status PRINTENV_FAILURE, not EXIT_FAILURE, on
command-line syntax problems.

src/printenv.c

index a956d250dc36a06b97d9bf321e90d264db388710..2545d46ff0a41ddb674edbf2b3d1ab1bb21862ae 100644 (file)
@@ -1,5 +1,5 @@
 /* printenv -- print all or part of environment
-   Copyright (C) 1989-1997, 1999-2003 Free Software Foundation, Inc.
+   Copyright (C) 1989-1997, 1999-2004 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@
    Exit status:
    0 if all variables specified were found
    1 if not
+   2 if some other error occurred
 
    David MacKenzie and Richard Mlynarik */
 
 
 #include "system.h"
 #include "error.h"
-#include "exitfail.h"
 #include "long-options.h"
 
+/* Exit status for syntax errors, etc.  */
+enum { PRINTENV_FAILURE = 2 };
+
 /* The official name of this program (e.g., no `g' prefix).  */
 #define PROGRAM_NAME "printenv"
 
@@ -55,7 +58,7 @@ extern char **environ;
 void
 usage (int status)
 {
-  if (status != 0)
+  if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
             program_name);
   else
@@ -90,7 +93,7 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  exit_failure = 2;
+  initialize_exit_failure (PRINTENV_FAILURE);
   atexit (close_stdout);
 
   parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -104,7 +107,7 @@ main (int argc, char **argv)
          break;
 
        default:
-         usage (EXIT_FAILURE);
+         usage (PRINTENV_FAILURE);
        }
     }
 
@@ -112,7 +115,7 @@ main (int argc, char **argv)
     {
       for (env = environ; *env != NULL; ++env)
        puts (*env);
-      exit_status = 0;
+      exit_status = EXIT_SUCCESS;
     }
   else
     {