mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
(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.
This commit is contained in:
1 parent
bdb46518ee
commit
57a460665c
1 file changed
+9
-6
+9
-6
@@ -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
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user