summaryrefslogtreecommitdiff
path: root/src/tty.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2004-01-22 21:09:33 +0000
committerJim Meyering <jim@meyering.net>2004-01-22 21:09:33 +0000
commitf915f22d851163de5e6e4d242c952a3f43743c81 (patch)
tree8ee7ab099121dff3a724c9fb96f10252a3eaa2ec /src/tty.c
parent5dd70584396397f184df27f6adabee9abd900131 (diff)
downloadcoreutils-f915f22d851163de5e6e4d242c952a3f43743c81.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. (TTY_FAILURE, TTY_WRITE_ERROR): New enum values; substitute them for the corresponding integer constants.
Diffstat (limited to 'src/tty.c')
-rw-r--r--src/tty.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/tty.c b/src/tty.c
index 076ac15d7..0e555182f 100644
--- a/src/tty.c
+++ b/src/tty.c
@@ -1,5 +1,5 @@
/* tty -- print the path of the terminal connected to standard input
- Copyright (C) 1990-2003 Free Software Foundation, Inc.
+ Copyright (C) 1990-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
@@ -28,9 +28,15 @@
#include <sys/types.h>
#include "system.h"
-#include "exitfail.h"
#include "error.h"
+/* Exit statuses. */
+enum
+ {
+ TTY_FAILURE = 2,
+ TTY_WRITE_ERROR = 3
+ };
+
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "tty"
@@ -54,7 +60,7 @@ static struct option const longopts[] =
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -84,7 +90,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- exit_failure = 3;
+ initialize_exit_failure (TTY_WRITE_ERROR);
atexit (close_stdout);
silent = 0;
@@ -105,7 +111,7 @@ main (int argc, char **argv)
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (2);
+ usage (TTY_FAILURE);
}
}
@@ -121,5 +127,5 @@ main (int argc, char **argv)
puts (_("not a tty"));
}
- exit (isatty (0) ? 0 : 1);
+ exit (isatty (0) ? EXIT_SUCCESS : EXIT_FAIL);
}