summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-01-22 20:44:15 +0000
committerJim Meyering <jim@meyering.net>2004-01-22 20:44:15 +0000
commit57a460665c96d702f9133ee83d258b6f6f29fcf6 (patch)
treee132505dfd995e8edf083069fc7acea559e8f3c7 /src
parentbdb46518eecbe0ba40f4a548463c73dee76526ed (diff)
downloadcoreutils-57a460665c96d702f9133ee83d258b6f6f29fcf6.tar.xz
(usage): Use EXIT_SUCCESS, not 0, for clarity.
(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.
Diffstat (limited to 'src')
-rw-r--r--src/printenv.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/printenv.c b/src/printenv.c
index a956d250d..2545d46ff 100644
--- a/src/printenv.c
+++ b/src/printenv.c
@@ -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 */
@@ -34,9 +35,11 @@
#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
{