[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
exit status patch for coreutils
From: |
Paul Eggert |
Subject: |
exit status patch for coreutils |
Date: |
21 Jan 2004 13:25:52 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Here's a proposed patch that's been lurking in my archives for a
while. I audited all the use of exit statuses in coreutils, and found
some problems. The worst example:
$ mkdir d d/e d/e/f
$ chmod a-w d
$ rmdir -p d d/e/f
rmdir: `d': Directory not empty
rmdir: `d/e': Permission denied
$ echo $?
0
The exit status should be 1, not 0.
I also noticed that EXIT_FAILURE might not equal 1, as POSIX does not
require it. I recall that it's not 1 on traditional VMS, though I
don't know if anyone uses coreutils on VMS or OpenVMS or whatever it's
called these days. The patch below also addresses this issue, by
adjusting the documentation slightly and introducing a new symbol
EXIT_FAIL for when programs want to return 1 even if EXIT_FAILURE
isn't 1.
Here's the patch.
Index: ChangeLog
===================================================================
RCS file: /home/meyering/coreutils/cu/ChangeLog,v
retrieving revision 1.750
diff -p -u -r1.750 ChangeLog
--- ChangeLog 20 Jan 2004 22:44:46 -0000 1.750
+++ ChangeLog 21 Jan 2004 15:33:49 -0000
@@ -1,3 +1,140 @@
+2004-01-21 Paul Eggert <address@hidden>
+
+ Exit status cleanup.
+
+ * src/basename.c (usage): Use EXIT_SUCCESS, not 0, for clarity.
+ * src/cat.c, src/chgrp.c, src/chmod.c, src/chown.c, src/chroot.c,
+ src/cksum.c, src/comm.c, src/cp.c, src/csplit.c, src/cut.c,
+ src/date.c, src/dd.c, src/df.c, src/dircolors.c, src/dirname.c,
+ src/du.c, src/echo.c, src/env.c, src/expand.c, src/expr.c,
+ src/factor.c, src/fmt.c, src/fold.c, src/head.c, src/hostid.c,
+ src/hostname.c, src/id.c, src/install.c, src/join.c, src/kill.c,
+ src/link.c, src/ln.c, src/logname.c, src/ls.c, src/md5sum.c,
+ src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mv.c, src/nice.c,
+ src/nl.c, src/nohup.c, src/od.c, src/paste.c, src/pathchk.c,
+ src/pinky.c, src/pr.c, src/printenv.c, src/printf.c, src/pwd.c,
+ src/rm.c, src/rmdir.c, src/seq.c, src/setuidgid.c, src/shred.c,
+ src/sleep.c, src/sort.c, src/split.c, src/stat.c, src/stty.c,
+ src/su.c, src/sum.c, src/sync.c, src/tac.c, src/tail.c, src/tee.c,
+ src/test.c, src/touch.c, src/tr.c, src/tsort.c, src/tty.c, src/uname.c,
+ src/unexpand.c, src/uniq.c, src/unlink.c, src/uptime.c, src/users.c,
+ src/wc.c, src/who.c, src/whoami.c, src/yes.c: Likewise.
+
+ * src/cat.c (usage): Don't bother normalizing exit status
+ since the arg is already the correct exit status now.
+ * src/cksum.c, src/comm.c, src/csplit.c, src/cut.c,
+ src/dircolors.c, src/expand.c, src/fmt.c, src/fold.c, src/head.c,
+ src/join.c, src/md5sum.c, src/nl.c, src/od.c, src/paste.c,
+ src/pr.c, src/split.c, src/sum.c, src/tac.c, src/tail.c, src/tr.c,
+ src/tsort.c, unexpand.c, src/src/uniq.c, src/src/wc.c: Likewise.
+
+ * src/chown.c (main): Removed unused local 'fail'.
+
+ * src/chroot.c (CHROOT_FOUND_BUT_CANNOT_INVOKE, CHROOT_FAILURE):
+ Remove.
+
+ * src/chroot.c (main): Initialize exit_failure to EXIT_FAIL.
+ * src/env.c, src/nice.c, src/su.c: Likewise.
+ * src/nohup.c (main): Likewise, to NOHUP_FAILURE.
+ * src/setuidgid.c (main): Likewise, to SETUIDGID_FAILURE.
+ * src/expr.c (main): Use initialize_exit_failure rather than
+ setting exit_failure directly; this optimizes away redundant
+ assignments.
+ * src/printenv.c, src/sort.c, src/test.c, src/tty.c: Likewise.
+ * src/system.h (initialize_exit_failure): New function.
+ Include exitfail.h here, since we refer to exit_failure.
+ All callers changed to not include exitfail.h.
+
+ * src/chroot.c (main): Exit with status 1 rather than 127
+ if chroot itself fails, as per documentation.
+
+ * src/chroot.c (main): Use EXIT_ENOENT and EXIT_CANNOT_INVOKE
+ rather than roll-your-own symbols or integers.
+ * src/env.c (main): Likewise.
+ * src/nohup.c (main): Likewise.
+ * src/su.c (run_shell): Likewise.
+
+ * src/cp.c (exit_status): Remove static var....
+ (main): Making it local here instead. Use =, not |=, to set it.
+
+ * src/cut.c (FATAL_ERROR, main): Exit with status EXIT_FAILURE,
+ not 2, on errors.
+ * src/date.c (batch_convert, main): Likewise.
+ * src/dd.c (dd_copy): Likewise.
+ * src/pr.c (first_last_page, main, getoptarg): Likewise.
+ * src/tr.c (main): Likewise.
+ * src/date.c (main): Don't assume EXIT_FAILURE == 1, as
+ POSIX doesn't require it.
+ * src/dd.c (write_output, skip, dd_copy): Likewise.
+ * src/df.c (main): Likewise.
+ * src/id.c (main): Likewise.
+ * src/install.c (main): Likewise.
+ * src/ln.c (main): Likewise.
+ * src/ls.c (main): Likewise.
+ * src/mv.c (main): Likewise.
+ * src/shred.c (main): Likewise.
+
+ * src/env.c (main): Exit with status 1, not 2, on errors detected
+ by env proper.
+ * src/hostname.c (main): Likewise.
+ * src/nl.c (main): Likewise.
+ * src/stty.c (main): Likewise.
+
+ * src/expr.c (EXPR_FAILURE): Renamed from EXPR_ERROR, for
+ consistency with the other programs' naming conventions.
+ All uses changed.
+
+ * src/factor.c (main): Do not report a usage error simply
+ because stdin has bad numbers.
+
+ * src/id.c (problems): Now a boolean int, not a counter,
+ so that we don't have to worry about int overflow. All uses changed.
+ * src/touch.c (err): Likewise.
+
+ * src/md5sum.c (main): Use int, not size_t, to store boolean int.
+
+ * src/mkfifo.c (main): Exit with status 1, not 4, if not implemented.
+ * src/mknod.c: Likewise.
+
+ * src/nice.c (main): Exit with status EXIT_FAIL, not EXIT_FAILURE,
+ on error; this is in case EXIT_FAILURE is unusual.
+ * src/su.c (main): Likewise.
+
+ * src/nohup.c (NOHUP_FOUND_BUT_CANNOT_INVOKE): Remove; all uses
+ changed to EXIT_CANNOT_INVOKE.
+
+ * src/printenv.c (PRINTENV_FAILURE): New constant.
+ (main): Exit with status PRINTENV_FAILURE, not EXIT_FAILURE, on
+ command-line syntax problems.
+
+ * src/rmdir.c (remove_parents): Don't set 'fail' to a negative number.
+ (main): Avoid integer overflow when seeing whether errors occurred.
+
+ * src/seq.c (print_numbers): Now returns void, not (zero) int.
+ All callers changed.
+ (main): Remove unused local variable 'errs'. Always exit successfully
+ if we reach the end.
+
+ * src/setuidgid.c (SETUIDGID_FAILURE): Renamed from FAIL_STATUS,
+ for consistency with other programs here. All uses changed.
+ (main): Use 'error' to exit rather than invoking 'exit' here.
+
+ * src/sort.c: Don't include <assert.h>.
+ (SORT_OUT_OF_ORDER, SORT_FAILURE): Now enums, not macros.
+ (usage): Don't use 'assert'.
+ (main): Remove redundant assignment to exit_failure.
+
+ * src/system.h (EXIT_FAIL, EXIT_CANNOT_INVOKE, EXIT_ENOENT):
+ New enum values.
+ (initialize_exit_failure): New inline function.
+
+ * src/tty.c (TTY_FAILURE, TTY_WRITE_ERROR): New enum values;
+ substitute them for the corresponding integer constants.
+
+ * tests/help-version (expected_failure_status_date): Remove, as
+ 'date' is now normal.
+ (expected_failure_status_nohup): New var.
+
2004-01-20 Jim Meyering <address@hidden>
* Version 5.1.2.
Index: NEWS
===================================================================
RCS file: /home/meyering/coreutils/cu/NEWS,v
retrieving revision 1.163
diff -p -u -r1.163 NEWS
--- NEWS 17 Jan 2004 13:49:17 -0000 1.163
+++ NEWS 21 Jan 2004 15:44:14 -0000
@@ -1,4 +1,19 @@
GNU coreutils NEWS -*- outline -*-
+
+** Bug fixes
+
+ rmdir -p exits with status 1 on error; formerly it sometimes exited
+ with status 0 when given more than one argument.
+
+ nohup now always exits with status 127 when it finds an error,
+ as POSIX requires; formerly it sometimes exited with status 1.
+
+ Several programs (including cut, date, dd, env, hostname, nl, pr,
+ stty, and tr) now always exit with status 1 when they find an error;
+ formerly they sometimes exited with status 2.
+
+ factor no longer reports a usage error if stdin has the wrong format.
+
* Major changes in release 5.1.1 (2004-01-17):
** Configuration option
Index: doc/ChangeLog
===================================================================
RCS file: /home/meyering/coreutils/cu/doc/ChangeLog,v
retrieving revision 1.130
diff -p -u -r1.130 ChangeLog
--- doc/ChangeLog 16 Jan 2004 07:53:22 -0000 1.130
+++ doc/ChangeLog 20 Jan 2004 05:26:11 -0000
@@ -1,3 +1,18 @@
+2004-01-19 Paul Eggert <address@hidden>
+
+ * coreutils.texi (Exit status): Document that ordinary failure
+ might not exit with status 1 on unusual platforms.
+ Mention chroot, env, nice, and su as having unusual exit
+ status patterns. Don't bother to mention true and false
+ since their exit status patterns are actually normal.
+ (sort invocation, su invocation): Mention its unusual exit
+ status pattern.
+ (chroot invocation): Simplify description of exit status 1.
+ Remove duplicate description of status 127.
+ (env invocation): Use consistent tenses; simplifiy description
+ of status 1.
+ (nice invocation): Likewise.
+
2003-12-15 Paul Eggert <address@hidden>
* coreutils.texi (touch invocation): touch -r and -d can now
Index: doc/coreutils.texi
===================================================================
RCS file: /home/meyering/coreutils/cu/doc/coreutils.texi,v
retrieving revision 1.149
diff -p -u -r1.149 coreutils.texi
--- doc/coreutils.texi 16 Jan 2004 07:53:19 -0000 1.149
+++ doc/coreutils.texi 20 Jan 2004 07:06:26 -0000
@@ -122,7 +122,7 @@
This manual documents version @value{VERSION} of the @sc{gnu} core
utilities, including the standard programs for text and file manipulation.
-Copyright @copyright{} 1994, 1995, 1996, 2000, 2001, 2002, 2003
+Copyright @copyright{} 1994, 1995, 1996, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
@quotation
@@ -632,19 +632,23 @@ context that requires a file name.
@macro exitstatus
An exit status of zero indicates success,
-and a value of @samp{1} indicates failure.
+and a nonzero value indicates failure.
@end macro
Nearly every command invocation yields an integral @dfn{exit status}
that can be used to change how other commands work.
For the vast majority of commands, an exit status of zero indicates
-success, and a value of @samp{1} indicates failure.
+success. Failure is indicated by a nonzero value---typically
address@hidden, though it may differ on unusual platforms as @acronym{POSIX}
+requires only that it be nonzero.
+
However, some of the programs documented here do produce
other exit status values and a few associate different
meanings with the values @samp{0} and @samp{1}.
Here are some of the exceptions:
address@hidden, @command{false}, @command{nohup}, @command{printenv},
address@hidden, @command{test}, @command{true}, @command{tty}.
address@hidden, @command{env}, @command{expr},
address@hidden, @command{nohup}, @command{printenv},
address@hidden, @command{su}, @command{test}, @command{tty}.
@node Backup options
@@ -3069,7 +3073,14 @@ In addition, if the final byte of an inp
@command{sort} silently supplies one. A line's trailing newline is not
part of the line for comparison purposes.
-Upon any error, @command{sort} exits with a status of @samp{2}.
address@hidden exit status of @command{sort}
+Exit status:
+
address@hidden
+0 if no error occurred
+1 if invoked with @option{-c} and the input is not properly sorted
+2 if an error occurred
address@hidden display
@vindex TMPDIR
If the environment variable @env{TMPDIR} is set, @command{sort} uses its
@@ -11529,11 +11540,9 @@ device files), copy them into place, too
Exit status:
@display
-1 if there are invalid options, if the chroot syscall fails,
- or if the subsequent @samp{chdir ("/")} fails
+1 if @command{chroot} itself fails
126 if @var{command} is found but cannot be invoked
127 if @var{command} cannot be found
-127 if @var{command} cannot be found
the exit status of @var{command} otherwise
@end display
@@ -11595,9 +11604,8 @@ Start with an empty environment, ignorin
Exit status:
@display
-0 if no @var{command} was specified and the environment was output
-1 if no @var{command} was specified and there was a write error while
- printing the environment
+0 if no @var{command} is specified and the environment is output
+1 if @command{env} itself fails
126 if @var{command} is found but cannot be invoked
127 if @var{command} cannot be found
the exit status of @var{command} otherwise
@@ -11654,9 +11662,8 @@ instead.
Exit status:
@display
-0 if no @var{command} was specified and the current priority was output
-1 if there are invalid options or if no @var{command} was specified and
- there was a write error
+0 if no @var{command} is specified and the current priority is output
+1 if @command{nice} itself fails
126 if @var{command} is found but cannot be invoked
127 if @var{command} cannot be found
the exit status of @var{command} otherwise
@@ -11834,6 +11841,16 @@ unless the user running @command{su} is
shell is restricted (see @option{-m} just above).
@end table
+
address@hidden exit status of @command{su}
+Exit status:
+
address@hidden
+1 if @command{su} itself fails
+126 if subshell is found but cannot be invoked
+127 if subshell cannot be found
+the exit status of the subshell otherwise
address@hidden display
@cindex wheel group, not supported
@cindex group wheel, not supported
Index: lib/ChangeLog
===================================================================
RCS file: /home/meyering/coreutils/cu/lib/ChangeLog,v
retrieving revision 1.723
diff -p -u -r1.723 ChangeLog
--- lib/ChangeLog 16 Jan 2004 10:10:49 -0000 1.723
+++ lib/ChangeLog 21 Jan 2004 15:29:24 -0000
@@ -1,3 +1,17 @@
+2004-01-21 Paul Eggert <address@hidden>
+
+ * argmatch.c (ARGMATCH_DIE) [! defined ARGMATCH_DIE]:
+ Include "exitfail.h", and use exit_failure rather than EXIT_FAILURE.
+ * argmatch.h: Comment fix to match the above.
+ * long-options.c (parse_long_options): Use prototype
+ for usage function arg. Pass it EXIT_SUCCESS rather than 0,
+ for clarity.
+ * obstack.c (obstack_exit_failure) [!defined _LIBC]:
+ Now a macro referring to exit_failure, instead of a separate
+ variable. Include "exitfail.h" to get it.
+ * xstrtol.h: Include "exitfail.h".
+ (STRTOL_FATAL_ERROR): Exit with status exit_failure, not 2.
+
2004-01-16 Jim Meyering <address@hidden>
Merge from gnulib.
Index: lib/argmatch.c
===================================================================
RCS file: /home/meyering/coreutils/cu/lib/argmatch.c,v
retrieving revision 1.30
diff -p -u -r1.30 argmatch.c
--- lib/argmatch.c 13 Sep 2003 22:12:21 -0000 1.30
+++ lib/argmatch.c 19 Jan 2004 23:26:27 -0000
@@ -1,7 +1,7 @@
/* argmatch.c -- find a match for a string in an array
- Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003 Free Software
- Foundation, Inc.
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 2003, 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
@@ -49,7 +49,8 @@
/* Non failing version of argmatch call this function after failing. */
#ifndef ARGMATCH_DIE
-# define ARGMATCH_DIE exit (EXIT_FAILURE)
+# include "exitfail.h"
+# define ARGMATCH_DIE exit (exit_failure)
#endif
#ifdef ARGMATCH_DIE_DECL
Index: lib/argmatch.h
===================================================================
RCS file: /home/meyering/coreutils/cu/lib/argmatch.h,v
retrieving revision 1.21
diff -p -u -r1.21 argmatch.h
--- lib/argmatch.h 22 Nov 2002 11:04:01 -0000 1.21
+++ lib/argmatch.h 19 Jan 2004 23:26:37 -0000
@@ -1,5 +1,7 @@
/* argmatch.h -- definitions and prototypes for argmatch.c
- Copyright (C) 1990, 1998, 1999, 2001, 2002 Free Software Foundation, Inc.
+
+ Copyright (C) 1990, 1998, 1999, 2001, 2002, 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
@@ -55,7 +57,7 @@ int argmatch (char const *arg, char cons
/* xargmatch calls this function when it fails. This function should not
return. By default, this is a function that calls ARGMATCH_DIE which
- in turn defaults to `exit (EXIT_FAILURE)'. */
+ in turn defaults to `exit (exit_failure)'. */
typedef void (*argmatch_exit_fn) (void);
extern argmatch_exit_fn argmatch_die;
Index: lib/long-options.c
===================================================================
RCS file: /home/meyering/coreutils/cu/lib/long-options.c,v
retrieving revision 1.22
diff -p -u -r1.22 long-options.c
--- lib/long-options.c 18 Oct 2003 08:11:09 -0000 1.22
+++ lib/long-options.c 19 Jan 2004 06:54:51 -0000
@@ -1,6 +1,6 @@
/* Utility to accept --help and --version options as unobtrusively as possible.
- Copyright (C) 1993, 1994, 1998, 1999, 2000, 2002, 2003 Free
+ Copyright (C) 1993, 1994, 1998, 1999, 2000, 2002, 2003, 2004 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -49,7 +49,7 @@ parse_long_options (int argc,
const char *command_name,
const char *package,
const char *version,
- void (*usage_func)(),
+ void (*usage_func) (int),
/* const char *author1, ...*/ ...)
{
int c;
@@ -66,7 +66,7 @@ parse_long_options (int argc,
switch (c)
{
case 'h':
- (*usage_func) (0);
+ (*usage_func) (EXIT_SUCCESS);
case 'v':
{
Index: lib/obstack.c
===================================================================
RCS file: /home/meyering/coreutils/cu/lib/obstack.c,v
retrieving revision 1.22
diff -p -u -r1.22 obstack.c
--- lib/obstack.c 25 Oct 2003 15:28:09 -0000 1.22
+++ lib/obstack.c 19 Jan 2004 23:27:23 -0000
@@ -1,7 +1,8 @@
/* obstack.c - subroutines used implicitly by object stack macros
Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997,
- 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1998, 1999, 2000, 2001, 2002, 2003, 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
@@ -86,10 +87,12 @@ void (*obstack_alloc_failed_handler) (vo
/* Exit value used when `print_and_abort' is used. */
# include <stdlib.h>
-# ifndef _LIBC
-# include "exit.h"
-# endif
+# ifdef _LIBC
int obstack_exit_failure = EXIT_FAILURE;
+# else
+# include "exitfail.h"
+# define obstack_exit_failure exit_failure
+# endif
/* The non-GNU-C macros copy the obstack into this global variable
to avoid multiple evaluation. */
Index: lib/xstrtol.h
===================================================================
RCS file: /home/meyering/coreutils/cu/lib/xstrtol.h,v
retrieving revision 1.17
diff -p -u -r1.17 xstrtol.h
--- lib/xstrtol.h 15 Oct 2003 07:26:36 -0000 1.17
+++ lib/xstrtol.h 19 Jan 2004 07:37:43 -0000
@@ -1,6 +1,6 @@
/* A more useful interface to strtol.
- Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003 Free
+ Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004 Free
Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,8 @@
#ifndef XSTRTOL_H_
# define XSTRTOL_H_ 1
+#include "exitfail.h"
+
/* Get uintmax_t. */
# if HAVE_INTTYPES_H
# include <inttypes.h>
@@ -81,7 +83,7 @@ _DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
while (0)
# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \
- _STRTOL_ERROR (2, Str, Argument_type_string, Err)
+ _STRTOL_ERROR (exit_failure, Str, Argument_type_string, Err)
# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \
_STRTOL_ERROR (0, Str, Argument_type_string, Err)
Index: src/basename.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/basename.c,v
retrieving revision 1.55
diff -p -u -r1.55 basename.c
--- src/basename.c 5 Nov 2003 03:53:19 -0000 1.55
+++ src/basename.c 20 Jan 2004 06:01:53 -0000
@@ -1,5 +1,5 @@
/* basename -- strip directory and suffix from filenames
- Copyright (C) 1990-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1990-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
@@ -45,7 +45,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/cat.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/cat.c,v
retrieving revision 1.92
diff -p -u -r1.92 cat.c
--- src/cat.c 18 Oct 2003 10:05:47 -0000 1.92
+++ src/cat.c 19 Jan 2004 23:29:25 -0000
@@ -1,5 +1,5 @@
/* cat -- concatenate files and print on the standard output.
- Copyright (C) 88, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 88, 90, 91, 1995-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
@@ -77,13 +77,13 @@ static char *line_num_end = line_buf + L
/* Preserves the `cat' function's local `newlines' between invocations. */
static int newlines2 = 0;
-/* Count of non-fatal error conditions. */
+/* Nonzero if a non-fatal error has occurred. */
static int exit_status = 0;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -122,7 +122,7 @@ With no FILE, or when FILE is -, read st
#endif
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Compute the next line number. */
Index: src/chgrp.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chgrp.c,v
retrieving revision 1.108
diff -p -u -r1.108 chgrp.c
--- src/chgrp.c 9 Nov 2003 21:04:20 -0000 1.108
+++ src/chgrp.c 19 Jan 2004 23:30:45 -0000
@@ -1,5 +1,5 @@
/* chgrp -- change group ownership of files
- Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-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
@@ -111,7 +111,7 @@ parse_group (const char *name, gid_t *g)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/chmod.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chmod.c,v
retrieving revision 1.99
diff -p -u -r1.99 chmod.c
--- src/chmod.c 9 Nov 2003 21:03:57 -0000 1.99
+++ src/chmod.c 19 Jan 2004 23:32:03 -0000
@@ -1,5 +1,5 @@
/* chmod -- change permission modes of files
- Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-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
@@ -262,7 +262,7 @@ process_files (char **files, int bit_fla
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/chown.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chown.c,v
retrieving revision 1.113
diff -p -u -r1.113 chown.c
--- src/chown.c 9 Nov 2003 21:10:11 -0000 1.113
+++ src/chown.c 20 Jan 2004 06:02:11 -0000
@@ -1,5 +1,5 @@
/* chown -- change user and group ownership of files
- Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-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
@@ -86,7 +86,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -171,7 +171,7 @@ main (int argc, char **argv)
int bit_flags = FTS_PHYSICAL;
struct Chown_option chopt;
- int fail = 0;
+ int fail;
int optc;
initialize_main (&argc, &argv);
Index: src/chroot.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/chroot.c,v
retrieving revision 1.40
diff -p -u -r1.40 chroot.c
--- src/chroot.c 4 Jan 2004 20:45:45 -0000 1.40
+++ src/chroot.c 20 Jan 2004 05:29:49 -0000
@@ -31,23 +31,13 @@
#define AUTHORS "Roland McGrath"
-/* Exit statuses. */
-enum
- {
- /* found the specified command but failed to invoke it. */
- CHROOT_FOUND_BUT_CANNOT_INVOKE = 126,
-
- /* `chroot' itself failed, or did not find the specified command. */
- CHROOT_FAILURE = 127
- };
-
/* The name this program was run with, for error messages. */
char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -80,6 +70,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (EXIT_FAIL);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -87,15 +78,14 @@ main (int argc, char **argv)
if (argc <= 1)
{
error (0, 0, _("too few arguments"));
- usage (CHROOT_FAILURE);
+ usage (EXIT_FAIL);
}
if (chroot (argv[1]))
- error (CHROOT_FAILURE, errno,
- _("cannot change root directory to %s"), argv[1]);
+ error (EXIT_FAIL, errno, _("cannot change root directory to %s"), argv[1]);
if (chdir ("/"))
- error (CHROOT_FAILURE, errno, _("cannot chdir to root directory"));
+ error (EXIT_FAIL, errno, _("cannot chdir to root directory"));
if (argc == 2)
{
@@ -116,9 +106,7 @@ main (int argc, char **argv)
execvp (argv[0], argv);
{
- int exit_status = (errno == ENOENT
- ? CHROOT_FAILURE
- : CHROOT_FOUND_BUT_CANNOT_INVOKE);
+ int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, _("cannot run command %s"), quote (argv[0]));
exit (exit_status);
}
Index: src/cksum.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/cksum.c,v
retrieving revision 1.68
diff -p -u -r1.68 cksum.c
--- src/cksum.c 5 Nov 2003 03:53:19 -0000 1.68
+++ src/cksum.c 19 Jan 2004 23:35:16 -0000
@@ -1,5 +1,5 @@
/* cksum -- calculate and print POSIX checksums and sizes of files
- Copyright (C) 92, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 92, 1995-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
@@ -273,7 +273,7 @@ cksum (const char *file, int print_name)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -291,7 +291,7 @@ Print CRC checksum and byte counts of ea
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
int
Index: src/comm.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/comm.c,v
retrieving revision 1.72
diff -p -u -r1.72 comm.c
--- src/comm.c 18 Oct 2003 10:05:47 -0000 1.72
+++ src/comm.c 20 Jan 2004 06:02:29 -0000
@@ -1,5 +1,5 @@
/* comm -- compare two sorted files line by line.
- Copyright (C) 86, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 86, 90, 91, 1995-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
@@ -64,7 +64,7 @@ static struct option const long_options[
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 +84,7 @@ Compare sorted files LEFT_FILE and RIGHT
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Output the line in linebuffer LINE to stream STREAM
Index: src/cp.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/cp.c,v
retrieving revision 1.190
diff -p -u -r1.190 cp.c
--- src/cp.c 4 Jan 2004 21:07:16 -0000 1.190
+++ src/cp.c 20 Jan 2004 06:02:35 -0000
@@ -1,5 +1,5 @@
/* cp.c -- file copying (main routines)
- Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation.
+ Copyright (C) 89, 90, 91, 1995-2004 Free Software Foundation.
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
@@ -116,9 +116,6 @@ static int const reply_vals[] =
I_ALWAYS_YES, I_ALWAYS_NO, I_ASK_USER
};
-/* The error code to return to the system. */
-static int exit_status = 0;
-
static struct option const long_opts[] =
{
{"archive", no_argument, NULL, 'a'},
@@ -153,7 +150,7 @@ static struct option const long_opts[] =
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -821,6 +818,7 @@ int
main (int argc, char **argv)
{
int c;
+ int exit_status;
int make_backups = 0;
char *backup_suffix_string;
char *version_control_string = NULL;
@@ -1046,7 +1044,7 @@ main (int argc, char **argv)
hash_init ();
- exit_status |= do_copy (argc - optind, argv + optind, target_directory, &x);
+ exit_status = do_copy (argc - optind, argv + optind, target_directory, &x);
forget_all ();
Index: src/csplit.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/csplit.c,v
retrieving revision 1.125
diff -p -u -r1.125 csplit.c
--- src/csplit.c 4 Jan 2004 21:08:47 -0000 1.125
+++ src/csplit.c 20 Jan 2004 06:02:44 -0000
@@ -1,5 +1,5 @@
/* csplit - split a file into sections determined by context lines
- Copyright (C) 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 91, 1995-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
@@ -1397,7 +1397,7 @@ main (int argc, char **argv)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -1442,5 +1442,5 @@ A line OFFSET is a required `+' or `-' f
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
Index: src/cut.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/cut.c,v
retrieving revision 1.108
diff -p -u -r1.108 cut.c
--- src/cut.c 6 Nov 2003 08:37:55 -0000 1.108
+++ src/cut.c 19 Jan 2004 23:40:57 -0000
@@ -1,5 +1,6 @@
/* cut - remove parts of lines of files
- Copyright (C) 1984, 1997-2003 by David M. Ihnat
+ Copyright (C) 1997-2004 Free Software Foundation, Inc.
+ Copyright (C) 1984 David M. Ihnat
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
@@ -45,7 +46,7 @@
do \
{ \
error (0, 0, (Message)); \
- usage (2); \
+ usage (EXIT_FAILURE); \
} \
while (0)
@@ -173,7 +174,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
@@ -221,7 +222,7 @@ With no FILE, or when FILE is -, read st
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
static inline void
@@ -794,7 +795,7 @@ main (int argc, char **argv)
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (2);
+ usage (EXIT_FAILURE);
}
}
Index: src/date.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/date.c,v
retrieving revision 1.131
diff -p -u -r1.131 date.c
--- src/date.c 4 Nov 2003 09:27:54 -0000 1.131
+++ src/date.c 20 Jan 2004 05:33:21 -0000
@@ -1,5 +1,5 @@
/* date - print or set the system date and time
- Copyright (C) 1989-2003 Free Software Foundation, Inc.
+ Copyright (C) 1989-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,7 +28,6 @@
#include "system.h"
#include "argmatch.h"
#include "error.h"
-#include "exitfail.h"
#include "getdate.h"
#include "getline.h"
#include "posixtm.h"
@@ -111,7 +110,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -277,7 +276,7 @@ batch_convert (const char *input_filenam
}
if (fclose (in_stream) == EOF)
- error (2, errno, "%s", quote (input_filename));
+ error (EXIT_FAILURE, errno, "%s", quote (input_filename));
if (line != NULL)
free (line);
@@ -310,7 +309,6 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- exit_failure = 2;
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, short_options, long_options, NULL))
@@ -476,7 +474,7 @@ argument must be a format string beginni
show_date (format, when);
}
- exit (status);
+ exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
/* Display the date and/or time in WHEN according to the format specified
Index: src/dd.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/dd.c,v
retrieving revision 1.153
diff -p -u -r1.153 dd.c
--- src/dd.c 20 Dec 2003 09:23:19 -0000 1.153
+++ src/dd.c 19 Jan 2004 19:38:07 -0000
@@ -1,5 +1,5 @@
/* dd -- convert a file while copying it.
- Copyright (C) 85, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 85, 90, 91, 1995-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
@@ -279,7 +279,7 @@ static char const ebcdic_to_ascii[] =
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -479,7 +479,7 @@ write_output (void)
error (0, errno, _("writing to %s"), quote (output_file));
if (nwritten != 0)
w_partial++;
- quit (1);
+ quit (EXIT_FAILURE);
}
else
w_full++;
@@ -823,7 +823,7 @@ skip (int fdesc, char const *file, uintm
if (nread == SAFE_READ_ERROR)
{
error (0, errno, _("reading %s"), quote (file));
- quit (1);
+ quit (EXIT_FAILURE);
}
/* POSIX doesn't say what to do when dd detects it has been
asked to skip past EOF, so I assume it's non-fatal.
@@ -937,7 +937,7 @@ dd_copy (void)
char *real_buf; /* real buffer address before alignment */
char *real_obuf;
size_t nread; /* Bytes read in the current block. */
- int exit_status = 0;
+ int exit_status = EXIT_SUCCESS;
size_t page_size = getpagesize ();
size_t n_bytes_read;
@@ -1032,7 +1032,7 @@ dd_copy (void)
else
{
/* Write any partial block. */
- exit_status = 2;
+ exit_status = EXIT_FAILURE;
break;
}
}
@@ -1061,7 +1061,7 @@ dd_copy (void)
if (nwritten != n_bytes_read)
{
error (0, errno, _("writing %s"), quote (output_file));
- quit (1);
+ quit (EXIT_FAILURE);
}
else if (n_bytes_read == input_blocksize)
w_full++;
@@ -1122,7 +1122,7 @@ dd_copy (void)
if (nwritten != oc)
{
error (0, errno, _("writing %s"), quote (output_file));
- quit (1);
+ quit (EXIT_FAILURE);
}
}
Index: src/df.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/df.c,v
retrieving revision 1.156
diff -p -u -r1.156 df.c
--- src/df.c 2 Nov 2003 20:22:54 -0000 1.156
+++ src/df.c 19 Jan 2004 23:45:11 -0000
@@ -1,5 +1,5 @@
/* df - summarize free disk space
- Copyright (C) 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 91, 1995-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
@@ -719,7 +719,7 @@ add_excluded_fs_type (const char *fstype
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -918,7 +918,7 @@ main (int argc, char **argv)
Fail if df was invoked with no file name arguments;
Otherwise, merely give a warning and proceed. */
const char *warning = (optind < argc ? _("Warning: ") : "");
- int status = (optind < argc ? 0 : 1);
+ int status = (optind < argc ? 0 : EXIT_FAILURE);
error (status, errno,
_("%scannot read table of mounted filesystems"), warning);
}
@@ -946,5 +946,5 @@ main (int argc, char **argv)
show_all_entries ();
}
- exit (exit_status);
+ exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
Index: src/dircolors.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/dircolors.c,v
retrieving revision 1.80
diff -p -u -r1.80 dircolors.c
--- src/dircolors.c 18 Oct 2003 10:05:47 -0000 1.80
+++ src/dircolors.c 20 Jan 2004 06:03:04 -0000
@@ -1,5 +1,5 @@
/* dircolors - output commands to set the LS_COLOR environment variable
- Copyright (C) 1996-2003 Free Software Foundation, Inc.
+ Copyright (C) 1996-2004 Free Software Foundation, Inc.
Copyright (C) 1994, 1995, 1997, 1998, 1999, 2000 H. Peter Anvin
This program is free software; you can redistribute it and/or modify
@@ -96,7 +96,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -121,7 +121,7 @@ For details on the format of these files
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* If the SHELL environment variable is set to `csh' or `tcsh,'
Index: src/dirname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/dirname.c,v
retrieving revision 1.61
diff -p -u -r1.61 dirname.c
--- src/dirname.c 5 Nov 2003 03:53:19 -0000 1.61
+++ src/dirname.c 19 Jan 2004 23:47:05 -0000
@@ -1,5 +1,5 @@
/* dirname -- strip filename suffix from pathname
- Copyright (C) 1990-1997, 1999-2002 Free Software Foundation, Inc.
+ Copyright (C) 1990-1997, 1999-2002, 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
@@ -37,7 +37,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/du.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/du.c,v
retrieving revision 1.180
diff -p -u -r1.180 du.c
--- src/du.c 4 Jan 2004 20:59:31 -0000 1.180
+++ src/du.c 19 Jan 2004 19:39:19 -0000
@@ -159,7 +159,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/echo.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/echo.c,v
retrieving revision 1.53
diff -p -u -r1.53 echo.c
--- src/echo.c 5 Nov 2003 03:53:19 -0000 1.53
+++ src/echo.c 19 Jan 2004 23:47:32 -0000
@@ -1,5 +1,5 @@
/* echo.c, derived from code echo.c in Bash.
- Copyright (C) 87,89, 1991-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 87,89, 1991-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
@@ -68,7 +68,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/env.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/env.c,v
retrieving revision 1.56
diff -p -u -r1.56 env.c
--- src/env.c 18 Oct 2003 10:05:47 -0000 1.56
+++ src/env.c 20 Jan 2004 06:03:28 -0000
@@ -1,5 +1,5 @@
/* env - run a program in a modified environment
- Copyright (C) 1986, 1991-2003 Free Software Foundation, Inc.
+ Copyright (C) 1986, 1991-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
@@ -110,7 +110,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
@@ -147,6 +147,7 @@ main (register int argc, register char *
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (EXIT_FAIL);
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
@@ -163,7 +164,7 @@ main (register int argc, register char *
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (2);
+ usage (EXIT_FAIL);
}
}
@@ -198,7 +199,7 @@ main (register int argc, register char *
execvp (argv[optind], &argv[optind]);
{
- int exit_status = (errno == ENOENT ? 127 : 126);
+ int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, "%s", argv[optind]);
exit (exit_status);
}
Index: src/expand.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/expand.c,v
retrieving revision 1.74
diff -p -u -r1.74 expand.c
--- src/expand.c 4 Jan 2004 21:10:11 -0000 1.74
+++ src/expand.c 19 Jan 2004 23:48:39 -0000
@@ -1,5 +1,5 @@
/* expand - convert tabs to spaces
- Copyright (C) 89, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 91, 1995-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
@@ -85,7 +85,7 @@ static char *stdin_argv[] =
/* Nonzero if we have ever read standard input. */
static int have_read_stdin;
-/* Status to return to the system. */
+/* Nonzero if errors have occurred. */
static int exit_status;
static struct option const longopts[] =
@@ -100,7 +100,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
@@ -128,7 +128,7 @@ Mandatory arguments to long options are
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Add tab stop TABVAL to the end of `tab_list', except
Index: src/expr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/expr.c,v
retrieving revision 1.90
diff -p -u -r1.90 expr.c
--- src/expr.c 5 Nov 2003 03:53:19 -0000 1.90
+++ src/expr.c 20 Jan 2004 05:31:47 -0000
@@ -1,5 +1,5 @@
/* expr -- evaluate expressions.
- Copyright (C) 86, 1991-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 86, 1991-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
@@ -36,7 +36,6 @@
#include <regex.h>
#include "long-options.h"
#include "error.h"
-#include "exitfail.h"
#include "inttostr.h"
#include "quotearg.h"
@@ -58,7 +57,7 @@ enum
EXPR_INVALID = 2,
/* Some other error occurred. */
- EXPR_ERROR
+ EXPR_FAILURE
};
/* The kinds of value we can have. */
@@ -95,7 +94,7 @@ static void printv (VALUE *v);
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -182,9 +181,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- /* Change the way library functions fail. */
- exit_failure = EXPR_ERROR;
-
+ initialize_exit_failure (EXPR_FAILURE);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -422,7 +419,7 @@ of the basic regular expression is not p
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
if (errmsg)
- error (EXPR_ERROR, 0, "%s", errmsg);
+ error (EXPR_FAILURE, 0, "%s", errmsg);
matchlen = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
if (0 <= matchlen)
@@ -607,13 +604,13 @@ eval4 (void)
return l;
r = eval5 ();
if (!toarith (l) || !toarith (r))
- error (EXPR_ERROR, 0, _("non-numeric argument"));
+ error (EXPR_FAILURE, 0, _("non-numeric argument"));
if (fxn == multiply)
val = l->u.i * r->u.i;
else
{
if (r->u.i == 0)
- error (EXPR_ERROR, 0, _("division by zero"));
+ error (EXPR_FAILURE, 0, _("division by zero"));
val = fxn == divide ? l->u.i / r->u.i : l->u.i % r->u.i;
}
freev (l);
@@ -646,7 +643,7 @@ eval3 (void)
return l;
r = eval4 ();
if (!toarith (l) || !toarith (r))
- error (EXPR_ERROR, 0, _("non-numeric argument"));
+ error (EXPR_FAILURE, 0, _("non-numeric argument"));
val = fxn == plus ? l->u.i + r->u.i : l->u.i - r->u.i;
freev (l);
freev (r);
@@ -713,7 +710,7 @@ eval2 (void)
{
error (0, collation_errno, _("string comparison failed"));
error (0, 0, _("Set LC_ALL='C' to work around the problem."));
- error (EXPR_ERROR, 0,
+ error (EXPR_FAILURE, 0,
_("The strings compared were %s and %s."),
quotearg_n_style (0, locale_quoting_style, collation_arg1),
quotearg_n_style (1, locale_quoting_style, r->u.s));
Index: src/factor.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/factor.c,v
retrieving revision 1.64
diff -p -u -r1.64 factor.c
--- src/factor.c 5 Nov 2003 03:53:19 -0000 1.64
+++ src/factor.c 20 Jan 2004 06:03:39 -0000
@@ -1,5 +1,5 @@
/* factor -- print prime factors of n.
- Copyright (C) 86, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 86, 1995-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
@@ -65,7 +65,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -219,9 +219,9 @@ main (int argc, char **argv)
int i;
for (i = 1; i < argc; i++)
fail |= print_factors (argv[i]);
+ if (fail)
+ usage (EXIT_FAILURE);
}
- if (fail)
- usage (EXIT_FAILURE);
- exit (fail);
+ exit (fail ? EXIT_FAILURE : EXIT_SUCCESS);
}
Index: src/fmt.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/fmt.c,v
retrieving revision 1.86
diff -p -u -r1.86 fmt.c
--- src/fmt.c 18 Oct 2003 10:05:47 -0000 1.86
+++ src/fmt.c 19 Jan 2004 23:51:49 -0000
@@ -1,5 +1,5 @@
/* GNU fmt -- simple text formatter.
- Copyright (C) 1994-2003 Free Software Foundation, Inc.
+ Copyright (C) 1994-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
@@ -263,7 +263,7 @@ static int last_line_length;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -296,7 +296,7 @@ With no FILE, or when FILE is -, read st
stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Decode options and launch execution. */
Index: src/fold.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/fold.c,v
retrieving revision 1.77
diff -p -u -r1.77 fold.c
--- src/fold.c 4 Jan 2004 21:00:49 -0000 1.77
+++ src/fold.c 19 Jan 2004 23:52:43 -0000
@@ -58,7 +58,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 +84,7 @@ Mandatory arguments to long options are
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Assuming the current column is COLUMN, return the column that
Index: src/head.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/head.c,v
retrieving revision 1.92
diff -p -u -r1.92 head.c
--- src/head.c 18 Oct 2003 10:05:47 -0000 1.92
+++ src/head.c 19 Jan 2004 23:53:26 -0000
@@ -1,5 +1,5 @@
/* head -- output first part of file(s)
- Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-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
@@ -105,7 +105,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -143,7 +143,7 @@ N may have a multiplier suffix: b 512, k
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
static void
Index: src/hostid.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/hostid.c,v
retrieving revision 1.24
diff -p -u -r1.24 hostid.c
--- src/hostid.c 5 Nov 2003 03:53:19 -0000 1.24
+++ src/hostid.c 19 Jan 2004 23:54:49 -0000
@@ -1,5 +1,7 @@
/* print the hexadecimal identifier for the current host
- Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
Inc.
+
+ Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 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
@@ -36,7 +38,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/hostname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/hostname.c,v
retrieving revision 1.48
diff -p -u -r1.48 hostname.c
--- src/hostname.c 5 Nov 2003 03:53:19 -0000 1.48
+++ src/hostname.c 19 Jan 2004 23:55:06 -0000
@@ -1,5 +1,5 @@
/* hostname - set or print the name of current host system
- Copyright (C) 1994-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1994-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
@@ -58,7 +58,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -119,7 +119,7 @@ main (int argc, char **argv)
}
else
{
- error (2, 0, _("too many arguments"));
+ error (0, 0, _("too many arguments"));
usage (EXIT_FAILURE);
}
Index: src/id.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/id.c,v
retrieving revision 1.73
diff -p -u -r1.73 id.c
--- src/id.c 18 Oct 2003 10:05:47 -0000 1.73
+++ src/id.c 19 Jan 2004 23:57:46 -0000
@@ -1,5 +1,5 @@
/* id -- print real and effective UIDs and GIDs
- Copyright (C) 1989-2003 Free Software Foundation, Inc.
+ Copyright (C) 1989-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
@@ -60,7 +60,7 @@ static int use_name = 0;
static uid_t ruid, euid;
static gid_t rgid, egid;
-/* The number of errors encountered so far. */
+/* Nonzero if errors have been encountered. */
static int problems = 0;
static struct option const longopts[] =
@@ -78,7 +78,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
@@ -194,7 +194,7 @@ main (int argc, char **argv)
print_full_info (argv[optind]);
putchar ('\n');
- exit (problems != 0);
+ exit (problems == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
/* Print the name or value of user ID UID. */
@@ -210,7 +210,7 @@ print_user (uid_t uid)
if (pwd == NULL)
{
error (0, 0, _("cannot find name for user ID %u"), uid);
- problems++;
+ problems = 1;
}
}
@@ -233,7 +233,7 @@ print_group (gid_t gid)
if (grp == NULL)
{
error (0, 0, _("cannot find name for group ID %u"), gid);
- problems++;
+ problems = 1;
}
}
@@ -293,7 +293,7 @@ print_group_list (const char *username)
pwd = getpwuid (ruid);
if (pwd == NULL)
- problems++;
+ problems = 1;
print_group (rgid);
if (egid != rgid)
@@ -311,7 +311,7 @@ print_group_list (const char *username)
if (xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&n_groups, &groups))
{
- ++problems;
+ problems = 1;
return;
}
@@ -337,14 +337,14 @@ print_full_info (const char *username)
printf ("uid=%u", (unsigned) ruid);
pwd = getpwuid (ruid);
if (pwd == NULL)
- problems++;
+ problems = 1;
else
printf ("(%s)", pwd->pw_name);
printf (" gid=%u", (unsigned) rgid);
grp = getgrgid (rgid);
if (grp == NULL)
- problems++;
+ problems = 1;
else
printf ("(%s)", grp->gr_name);
@@ -353,7 +353,7 @@ print_full_info (const char *username)
printf (" euid=%u", (unsigned) euid);
pwd = getpwuid (euid);
if (pwd == NULL)
- problems++;
+ problems = 1;
else
printf ("(%s)", pwd->pw_name);
}
@@ -363,7 +363,7 @@ print_full_info (const char *username)
printf (" egid=%u", (unsigned) egid);
grp = getgrgid (egid);
if (grp == NULL)
- problems++;
+ problems = 1;
else
printf ("(%s)", grp->gr_name);
}
@@ -377,7 +377,7 @@ print_full_info (const char *username)
if (xgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
&n_groups, &groups))
{
- ++problems;
+ problems = 1;
return;
}
@@ -390,7 +390,7 @@ print_full_info (const char *username)
printf ("%u", (unsigned) groups[i]);
grp = getgrgid (groups[i]);
if (grp == NULL)
- problems++;
+ problems = 1;
else
printf ("(%s)", grp->gr_name);
}
Index: src/install.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/install.c,v
retrieving revision 1.156
diff -p -u -r1.156 install.c
--- src/install.c 18 Oct 2003 10:05:47 -0000 1.156
+++ src/install.c 19 Jan 2004 23:59:15 -0000
@@ -1,5 +1,5 @@
/* install - copy files and set attributes
- Copyright (C) 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 90, 91, 1995-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
@@ -341,7 +341,7 @@ is not a directory"),
}
}
- exit (errors);
+ exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
/* Copy file FROM onto file TO, creating any missing parent directories of TO.
@@ -585,7 +585,7 @@ get_ids (void)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/join.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/join.c,v
retrieving revision 1.125
diff -p -u -r1.125 join.c
--- src/join.c 30 Dec 2003 08:26:58 -0000 1.125
+++ src/join.c 19 Jan 2004 23:59:59 -0000
@@ -1,5 +1,5 @@
/* join - join lines of two files on a common field
- Copyright (C) 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 91, 1995-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
@@ -150,7 +150,7 @@ get_option (int argc, char **argv)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -194,7 +194,7 @@ Important: FILE1 and FILE2 must be sorte
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Return true if C is a blank (a default input field separator). */
Index: src/kill.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/kill.c,v
retrieving revision 1.13
diff -p -u -r1.13 kill.c
--- src/kill.c 18 Oct 2003 10:05:47 -0000 1.13
+++ src/kill.c 20 Jan 2004 00:00:12 -0000
@@ -1,5 +1,5 @@
/* kill -- send a signal to a process
- Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 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
@@ -86,7 +86,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/link.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/link.c,v
retrieving revision 1.10
diff -p -u -r1.10 link.c
--- src/link.c 5 Nov 2003 03:53:19 -0000 1.10
+++ src/link.c 20 Jan 2004 00:00:23 -0000
@@ -1,5 +1,5 @@
/* link utility for GNU.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 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
@@ -43,7 +43,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/ln.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/ln.c,v
retrieving revision 1.132
diff -p -u -r1.132 ln.c
--- src/ln.c 18 Oct 2003 10:05:47 -0000 1.132
+++ src/ln.c 20 Jan 2004 00:01:29 -0000
@@ -1,5 +1,5 @@
/* `ln' program to create links between files.
- Copyright (C) 86, 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 86, 89, 90, 91, 1995-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
@@ -337,7 +337,7 @@ do_link (const char *source, const char
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -580,5 +580,5 @@ main (int argc, char **argv)
errors = do_link (source, new_dest);
}
- exit (errors != 0);
+ exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
Index: src/logname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/logname.c,v
retrieving revision 1.52
diff -p -u -r1.52 logname.c
--- src/logname.c 5 Nov 2003 03:53:19 -0000 1.52
+++ src/logname.c 20 Jan 2004 00:01:35 -0000
@@ -1,5 +1,5 @@
/* logname -- print user's login name
- Copyright (C) 1990-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1990-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
@@ -40,7 +40,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/ls.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/ls.c,v
retrieving revision 1.350
diff -p -u -r1.350 ls.c
--- src/ls.c 24 Dec 2003 16:38:36 -0000 1.350
+++ src/ls.c 20 Jan 2004 00:03:33 -0000
@@ -1,5 +1,5 @@
/* `dir', `vdir' and `ls' directory listing programs for GNU.
- Copyright (C) 85, 88, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 85, 88, 90, 91, 1995-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
@@ -662,7 +662,7 @@ static char const *long_time_format[2] =
N_("%b %e %H:%M")
};
-/* The exit status to use if we don't get any fatal errors. */
+/* Nonzero if a non-fatal error has occurred. */
static int exit_status;
@@ -1210,7 +1210,7 @@ main (int argc, char **argv)
hash_free (active_dir_set);
}
- exit (exit_status);
+ exit (exit_status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
/* Set all the option flags according to the switches specified.
@@ -3903,7 +3903,7 @@ calculate_columns (bool by_columns)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/md5sum.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/md5sum.c,v
retrieving revision 1.120
diff -p -u -r1.120 md5sum.c
--- src/md5sum.c 2 Dec 2003 10:06:36 -0000 1.120
+++ src/md5sum.c 20 Jan 2004 00:04:59 -0000
@@ -1,5 +1,5 @@
/* Compute MD5 or SHA1 checksum of files or strings
- Copyright (C) 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 1995-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
@@ -116,7 +116,7 @@ static const struct option long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -156,7 +156,7 @@ text), and name for each FILE.\n"),
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
#define ISWHITE(c) ((c) == ' ' || (c) == '\t')
@@ -546,7 +546,7 @@ main (int argc, char **argv)
int opt;
char **string = NULL;
size_t n_strings = 0;
- size_t err = 0;
+ int err = 0;
int file_type_specified = 0;
#if O_BINARY
Index: src/mkdir.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mkdir.c,v
retrieving revision 1.87
diff -p -u -r1.87 mkdir.c
--- src/mkdir.c 18 Oct 2003 10:05:47 -0000 1.87
+++ src/mkdir.c 20 Jan 2004 00:05:27 -0000
@@ -1,5 +1,5 @@
/* mkdir -- make directories
- Copyright (C) 90, 1995-2002 Free Software Foundation, Inc.
+ Copyright (C) 90, 1995-2002, 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
@@ -53,7 +53,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
Index: src/mkfifo.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mkfifo.c,v
retrieving revision 1.69
diff -p -u -r1.69 mkfifo.c
--- src/mkfifo.c 18 Oct 2003 10:05:47 -0000 1.69
+++ src/mkfifo.c 20 Jan 2004 00:05:44 -0000
@@ -1,5 +1,5 @@
/* mkfifo -- make fifo's (named pipes)
- Copyright (C) 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 1995-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
@@ -47,7 +47,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
@@ -91,7 +91,7 @@ main (int argc, char **argv)
specified_mode = NULL;
#ifndef S_ISFIFO
- error (4, 0, _("fifo files not supported"));
+ error (EXIT_FAILURE, 0, _("fifo files not supported"));
#else
while ((optc = getopt_long (argc, argv, "m:", longopts, NULL)) != -1)
{
Index: src/mknod.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mknod.c,v
retrieving revision 1.78
diff -p -u -r1.78 mknod.c
--- src/mknod.c 18 Oct 2003 10:05:47 -0000 1.78
+++ src/mknod.c 20 Jan 2004 00:06:07 -0000
@@ -1,5 +1,5 @@
/* mknod -- make special files
- Copyright (C) 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 1995-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
@@ -47,7 +47,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
@@ -151,7 +151,7 @@ main (int argc, char **argv)
{
case 'b': /* `block' or `buffered' */
#ifndef S_IFBLK
- error (4, 0, _("block special files not supported"));
+ error (EXIT_FAILURE, 0, _("block special files not supported"));
#else
node_type = S_IFBLK;
#endif
@@ -160,7 +160,7 @@ main (int argc, char **argv)
case 'c': /* `character' */
case 'u': /* `unbuffered' */
#ifndef S_IFCHR
- error (4, 0, _("character special files not supported"));
+ error (EXIT_FAILURE, 0, _("character special files not supported"));
#else
node_type = S_IFCHR;
#endif
@@ -204,7 +204,7 @@ numbers must be specified"));
case 'p': /* `pipe' */
#ifndef S_ISFIFO
- error (4, 0, _("fifo files not supported"));
+ error (EXIT_FAILURE, 0, _("fifo files not supported"));
#else
if (argc - optind != 2)
{
Index: src/mv.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/mv.c,v
retrieving revision 1.150
diff -p -u -r1.150 mv.c
--- src/mv.c 9 Nov 2003 20:50:37 -0000 1.150
+++ src/mv.c 20 Jan 2004 00:06:56 -0000
@@ -1,5 +1,5 @@
/* mv -- move or rename files
- Copyright (C) 86, 89, 90, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 86, 89, 90, 91, 1995-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
@@ -298,7 +298,7 @@ movefile (char *source, char *dest, int
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -497,5 +497,5 @@ main (int argc, char **argv)
errors |= movefile (file[i], target_directory, dest_is_dir, &x);
}
- exit (errors);
+ exit (errors == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
Index: src/nice.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/nice.c,v
retrieving revision 1.74
diff -p -u -r1.74 nice.c
--- src/nice.c 5 Nov 2003 03:53:19 -0000 1.74
+++ src/nice.c 20 Jan 2004 06:04:18 -0000
@@ -1,5 +1,5 @@
/* nice -- run a program with modified scheduling priority
- 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
@@ -61,7 +61,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
@@ -96,6 +96,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (EXIT_FAIL);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -109,7 +110,7 @@ main (int argc, char **argv)
&& posix2_version () < 200112)
{
if (xstrtol (&s[2], NULL, 10, &adjustment, "") != LONGINT_OK)
- error (EXIT_FAILURE, 0, _("invalid option `%s'"), s);
+ error (EXIT_FAIL, 0, _("invalid option `%s'"), s);
minusflag = 1;
adjustment_given = 1;
@@ -122,7 +123,7 @@ main (int argc, char **argv)
if (s[1] == '+')
++s;
if (xstrtol (&s[1], NULL, 10, &adjustment, "") != LONGINT_OK)
- error (EXIT_FAILURE, 0, _("invalid option `%s'"), s);
+ error (EXIT_FAIL, 0, _("invalid option `%s'"), s);
minusflag = 0;
adjustment_given = 1;
@@ -142,12 +143,12 @@ main (int argc, char **argv)
switch (optc)
{
case '?':
- usage (EXIT_FAILURE);
+ usage (EXIT_FAIL);
case 'n':
if (xstrtol (optarg, NULL, 10, &adjustment, "")
!= LONGINT_OK)
- error (EXIT_FAILURE, 0, _("invalid priority `%s'"), optarg);
+ error (EXIT_FAIL, 0, _("invalid priority `%s'"), optarg);
minusflag = 0;
adjustment_given = 1;
@@ -172,13 +173,13 @@ main (int argc, char **argv)
if (adjustment_given)
{
error (0, 0, _("a command must be given with an adjustment"));
- usage (EXIT_FAILURE);
+ usage (EXIT_FAIL);
}
/* No command given; print the priority. */
errno = 0;
current_priority = GET_PRIORITY ();
if (current_priority == -1 && errno != 0)
- error (EXIT_FAILURE, errno, _("cannot get priority"));
+ error (EXIT_FAIL, errno, _("cannot get priority"));
printf ("%d\n", current_priority);
exit (EXIT_SUCCESS);
}
@@ -187,17 +188,17 @@ main (int argc, char **argv)
errno = 0;
current_priority = GET_PRIORITY ();
if (current_priority == -1 && errno != 0)
- error (EXIT_FAILURE, errno, _("cannot get priority"));
+ error (EXIT_FAIL, errno, _("cannot get priority"));
if (setpriority (PRIO_PROCESS, 0, current_priority + adjustment))
#else
if (nice (adjustment) == -1)
#endif
- error (EXIT_FAILURE, errno, _("cannot set priority"));
+ error (EXIT_FAIL, errno, _("cannot set priority"));
execvp (argv[i], &argv[i]);
{
- int exit_status = (errno == ENOENT ? 127 : 126);
+ int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, "%s", argv[i]);
exit (exit_status);
}
Index: src/nl.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/nl.c,v
retrieving revision 1.78
diff -p -u -r1.78 nl.c
--- src/nl.c 18 Oct 2003 10:05:47 -0000 1.78
+++ src/nl.c 20 Jan 2004 00:08:57 -0000
@@ -1,5 +1,5 @@
/* nl -- number lines of files
- Copyright (C) 89, 92, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 92, 1995-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
@@ -168,7 +168,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
@@ -226,7 +226,7 @@ FORMAT is one of:\n\
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Build the printf format string, based on `lineno_format'. */
@@ -606,7 +606,7 @@ main (int argc, char **argv)
}
if (fail)
- usage (2);
+ usage (EXIT_FAILURE);
/* Initialize the section delimiters. */
len = strlen (section_del);
Index: src/nohup.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/nohup.c,v
retrieving revision 1.9
diff -p -u -r1.9 nohup.c
--- src/nohup.c 5 Nov 2003 03:53:19 -0000 1.9
+++ src/nohup.c 20 Jan 2004 05:30:30 -0000
@@ -1,5 +1,5 @@
/* nohup -- run a command immume to hangups, with output to a non-tty
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 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
@@ -36,10 +36,7 @@
/* Exit statuses. */
enum
{
- /* `nohup' found the specified command but failed to invoke it. */
- NOHUP_FOUND_BUT_CANNOT_INVOKE = 126,
-
- /* `nohup' itself failed, or did not find the specified command. */
+ /* `nohup' itself failed. */
NOHUP_FAILURE = 127
};
@@ -48,7 +45,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -83,6 +80,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (NOHUP_FAILURE);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -173,9 +171,7 @@ main (int argc, char **argv)
char **cmd = argv + 1;
execvp (*cmd, cmd);
- exit_status = (errno == ENOENT
- ? NOHUP_FAILURE
- : NOHUP_FOUND_BUT_CANNOT_INVOKE);
+ exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
saved_errno = errno;
/* The execve failed. Output a diagnostic to stderr only if:
Index: src/od.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/od.c,v
retrieving revision 1.145
diff -p -u -r1.145 od.c
--- src/od.c 18 Nov 2003 16:17:00 -0000 1.145
+++ src/od.c 20 Jan 2004 00:09:58 -0000
@@ -1,5 +1,5 @@
/* od -- dump files in octal and other formats
- Copyright (C) 92, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 92, 1995-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
@@ -278,7 +278,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -368,7 +368,7 @@ implies 32. By default, od uses -A o -t
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Compute the greatest common denominator of U and V
Index: src/paste.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/paste.c,v
retrieving revision 1.70
diff -p -u -r1.70 paste.c
--- src/paste.c 9 Jan 2004 16:05:36 -0000 1.70
+++ src/paste.c 20 Jan 2004 06:04:36 -0000
@@ -1,5 +1,6 @@
/* paste - merge lines of files
- Copyright (C) 1984, 1997-2003 by David M. Ihnat
+ Copyright (C) 1997-2004 Free Software Foundation, Inc.
+ Copyright (C) 1984 David M. Ihnat
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
@@ -387,7 +388,7 @@ paste_serial (size_t nfiles, char **fnam
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -414,7 +415,7 @@ Mandatory arguments to long options are
/* FIXME: add a couple of examples. */
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
int
Index: src/pathchk.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/pathchk.c,v
retrieving revision 1.75
diff -p -u -r1.75 pathchk.c
--- src/pathchk.c 5 Nov 2003 03:53:19 -0000 1.75
+++ src/pathchk.c 20 Jan 2004 00:12:20 -0000
@@ -1,5 +1,5 @@
/* pathchk -- check whether pathnames are valid or portable
- Copyright (C) 1991-2003 Free Software Foundation, Inc.
+ Copyright (C) 1991-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
@@ -132,7 +132,7 @@ pathconf_wrapper (const char *filename,
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/pinky.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/pinky.c,v
retrieving revision 1.37
diff -p -u -r1.37 pinky.c
--- src/pinky.c 18 Oct 2003 10:05:47 -0000 1.37
+++ src/pinky.c 20 Jan 2004 00:12:31 -0000
@@ -1,5 +1,5 @@
/* GNU's pinky.
- Copyright (C) 1992-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1992-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
@@ -460,7 +460,7 @@ long_pinky (const int argc_names, char *
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/pr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/pr.c,v
retrieving revision 1.117
diff -p -u -r1.117 pr.c
--- src/pr.c 20 Dec 2003 16:44:12 -0000 1.117
+++ src/pr.c 20 Jan 2004 00:12:41 -0000
@@ -1,5 +1,5 @@
/* pr -- convert text files for printing.
- Copyright (C) 88, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 88, 91, 1995-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
@@ -801,7 +801,7 @@ first_last_page (char *pages)
if (*pages == ':')
{
error (0, 0, _("`--pages' invalid range of page numbers: `%s'"), pages);
- usage (2);
+ usage (EXIT_FAILURE);
}
str1 = strchr (pages, ':');
@@ -1068,7 +1068,7 @@ main (int argc, char **argv)
case_GETOPT_HELP_CHAR;
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (2);
+ usage (EXIT_FAILURE);
break;
}
}
@@ -1186,7 +1186,7 @@ getoptarg (char *arg, char switch_char,
error (0, 0,
_("`-%c' extra characters or invalid number in the argument:
`%s'"),
switch_char, arg);
- usage (2);
+ usage (EXIT_FAILURE);
}
*number = (int) tmp_long;
}
@@ -2744,7 +2744,7 @@ cleanup (void)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -2859,5 +2859,5 @@ FILE is -, read standard input.\n\
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
Index: src/printenv.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/printenv.c,v
retrieving revision 1.49
diff -p -u -r1.49 printenv.c
--- src/printenv.c 5 Nov 2003 03:53:19 -0000 1.49
+++ src/printenv.c 20 Jan 2004 05:29:49 -0000
@@ -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
{
Index: src/printf.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/printf.c,v
retrieving revision 1.86
diff -p -u -r1.86 printf.c
--- src/printf.c 27 Nov 2003 08:02:18 -0000 1.86
+++ src/printf.c 20 Jan 2004 06:04:50 -0000
@@ -1,5 +1,5 @@
/* printf - format and print data
- 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
@@ -87,7 +87,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/pwd.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/pwd.c,v
retrieving revision 1.43
diff -p -u -r1.43 pwd.c
--- src/pwd.c 5 Nov 2003 03:53:19 -0000 1.43
+++ src/pwd.c 20 Jan 2004 00:13:42 -0000
@@ -1,5 +1,5 @@
/* pwd - print current directory
- Copyright (C) 1994-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1994-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
@@ -37,7 +37,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/rm.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/rm.c,v
retrieving revision 1.125
diff -p -u -r1.125 rm.c
--- src/rm.c 9 Nov 2003 21:09:27 -0000 1.125
+++ src/rm.c 20 Jan 2004 00:13:52 -0000
@@ -1,5 +1,5 @@
/* `rm' file deletion utility for GNU.
- Copyright (C) 88, 90, 91, 1994-2003 Free Software Foundation, Inc.
+ Copyright (C) 88, 90, 91, 1994-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
@@ -99,7 +99,7 @@ static struct option const long_opts[] =
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/rmdir.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/rmdir.c,v
retrieving revision 1.74
diff -p -u -r1.74 rmdir.c
--- src/rmdir.c 18 Oct 2003 10:05:47 -0000 1.74
+++ src/rmdir.c 20 Jan 2004 00:18:42 -0000
@@ -1,5 +1,5 @@
/* rmdir -- remove directories
- Copyright (C) 90, 91, 1995-2002 Free Software Foundation, Inc.
+ Copyright (C) 90, 91, 1995-2002, 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
@@ -91,7 +91,8 @@ errno_rmdir_non_empty (int error_number)
/* Remove any empty parent directories of PATH.
If PATH contains slash characters, at least one of them
- (beginning with the rightmost) is replaced with a NUL byte. */
+ (beginning with the rightmost) is replaced with a NUL byte.
+ Return zero if successful. */
static int
remove_parents (char *path)
@@ -115,7 +116,7 @@ remove_parents (char *path)
if (verbose)
error (0, 0, _("removing directory, %s"), path);
- fail = rmdir (path);
+ fail = (rmdir (path) != 0);
if (fail)
{
@@ -138,7 +139,7 @@ remove_parents (char *path)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -230,7 +231,7 @@ main (int argc, char **argv)
}
else if (empty_paths)
{
- errors += remove_parents (dir);
+ errors |= remove_parents (dir);
}
}
Index: src/seq.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/seq.c,v
retrieving revision 1.76
diff -p -u -r1.76 seq.c
--- src/seq.c 27 Nov 2003 08:14:39 -0000 1.76
+++ src/seq.c 20 Jan 2004 00:19:22 -0000
@@ -1,5 +1,5 @@
/* seq - print sequence of numbers to standard output.
- Copyright (C) 1994-2003 Free Software Foundation, Inc.
+ Copyright (C) 1994-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
@@ -74,7 +74,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -176,7 +176,7 @@ valid_format (const char *fmt)
/* Actually print the sequence of numbers in the specified range, with the
given or default stepping and format. */
-static int
+static void
print_numbers (const char *fmt)
{
int i;
@@ -193,8 +193,6 @@ print_numbers (const char *fmt)
if (i)
fputs (terminator, stdout);
-
- return 0;
}
#if HAVE_RINT && HAVE_MODF && HAVE_FLOOR
@@ -297,7 +295,6 @@ get_width_format (void)
int
main (int argc, char **argv)
{
- int errs;
int optc;
/* The printf(3) format used for output. */
@@ -417,7 +414,7 @@ format string may not be specified when
format_str = "%g";
}
- errs = print_numbers (format_str);
+ print_numbers (format_str);
- exit (errs);
+ exit (EXIT_SUCCESS);
}
Index: src/setuidgid.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/setuidgid.c,v
retrieving revision 1.8
diff -p -u -r1.8 setuidgid.c
--- src/setuidgid.c 5 Nov 2003 03:53:19 -0000 1.8
+++ src/setuidgid.c 20 Jan 2004 07:42:01 -0000
@@ -1,5 +1,5 @@
/* setuidgid - run a command with the UID and GID of a specified user
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 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
@@ -35,14 +35,14 @@
D.J. Bernstein's program: http://cr.yp.to/daemontools/setuidgid.html. */
#define AUTHORS "Jim Meyering"
-#define FAIL_STATUS 111
+#define SETUIDGID_FAILURE 111
char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -80,6 +80,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (SETUIDGID_FAILURE);
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
@@ -96,40 +97,33 @@ main (int argc, char **argv)
if (argc <= 2)
{
error (0, 0, _("too few arguments"));
- usage (FAIL_STATUS);
+ usage (SETUIDGID_FAILURE);
}
user_id = argv[1];
pwd = getpwnam (user_id);
if (pwd == NULL)
- {
- error (0, errno, _("unknown user-ID: %s"), quote (user_id));
- exit (FAIL_STATUS);
- }
+ error (SETUIDGID_FAILURE, errno,
+ _("unknown user-ID: %s"), quote (user_id));
if (setgroups (1, &pwd->pw_gid))
- {
- error (0, errno, _("cannot set supplemental group"));
- exit (FAIL_STATUS);
- }
+ error (SETUIDGID_FAILURE, errno, _("cannot set supplemental group"));
if (setgid (pwd->pw_gid))
- {
- error (0, errno, _("cannot set group-ID to %ld"), (long) pwd->pw_gid);
- exit (FAIL_STATUS);
- }
+ error (SETUIDGID_FAILURE, errno,
+ _("cannot set group-ID to %ld"), (long int) pwd->pw_gid);
if (setuid (pwd->pw_uid))
- {
- error (0, errno, _("cannot set user-ID to %ld"), (long) pwd->pw_uid);
- exit (FAIL_STATUS);
- }
+ error (SETUIDGID_FAILURE, errno,
+ _("cannot set user-ID to %ld"), (long int) pwd->pw_uid);
{
char **cmd = argv + 2;
+ int exit_status;
execvp (*cmd, cmd);
+ exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, _("cannot run command %s"), quote (*cmd));
- exit (FAIL_STATUS);
+ exit (exit_status);
}
}
Index: src/shred.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/shred.c,v
retrieving revision 1.83
diff -p -u -r1.83 shred.c
--- src/shred.c 18 Oct 2003 10:05:47 -0000 1.83
+++ src/shred.c 20 Jan 2004 00:20:37 -0000
@@ -1,6 +1,6 @@
/* shred.c - overwrite files and devices to make it harder to recover data
- Copyright (C) 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1999-2004 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999 Colin Plumb.
This program is free software; you can redistribute it and/or modify
@@ -151,7 +151,7 @@ char const *program_name; /* Initialized
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -1622,7 +1622,7 @@ main (int argc, char **argv)
/* Just on general principles, wipe s. */
memset (&s, 0, sizeof s);
- exit (err);
+ exit (err == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
/*
* vim:sw=2:sts=2:
Index: src/sleep.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/sleep.c,v
retrieving revision 1.83
diff -p -u -r1.83 sleep.c
--- src/sleep.c 27 Nov 2003 08:16:38 -0000 1.83
+++ src/sleep.c 20 Jan 2004 00:20:54 -0000
@@ -1,5 +1,5 @@
/* sleep - delay for a specified amount of time.
- Copyright (C) 84, 1991-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 84, 1991-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
@@ -44,7 +44,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/sort.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/sort.c,v
retrieving revision 1.279
diff -p -u -r1.279 sort.c
--- src/sort.c 4 Jan 2004 21:12:00 -0000 1.279
+++ src/sort.c 20 Jan 2004 05:29:49 -0000
@@ -1,5 +1,5 @@
/* sort - sort lines of text (with all kinds of options).
- Copyright (C) 88, 1991-2003 Free Software Foundation, Inc.
+ Copyright (C) 88, 1991-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
@@ -27,10 +27,8 @@
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
-#include <assert.h>
#include "system.h"
#include "error.h"
-#include "exitfail.h"
#include "hard-locale.h"
#include "inttostr.h"
#include "long-options.h"
@@ -73,13 +71,17 @@ double strtod ();
# define DEFAULT_TMPDIR "/tmp"
#endif
-/* Use this as exit status in case of error, not EXIT_FAILURE. This
- is necessary because EXIT_FAILURE is usually 1 and POSIX requires
- that sort exit with status 1 IFF invoked with -c and the input is
- not properly sorted. Any other irregular exit must exit with a
- status code greater than 1. */
-#define SORT_FAILURE 2
-#define SORT_OUT_OF_ORDER 1
+/* Exit statuses. */
+enum
+ {
+ /* POSIX says to exit with status 1 if invoked with -c and the
+ input is not properly sorted. */
+ SORT_OUT_OF_ORDER = 1,
+
+ /* POSIX says any other irregular exit must exit with a status
+ code greater than 1. */
+ SORT_FAILURE = 2
+ };
#define C_DECIMAL_POINT '.'
#define NEGATION_SIGN '-'
@@ -266,7 +268,7 @@ static void sortlines_temp (struct line
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -340,10 +342,7 @@ native byte values.\n\
"), stdout );
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- /* Don't use EXIT_FAILURE here in case it is defined to be 1.
- POSIX requires that sort return 1 IFF invoked with -c and
- the input is not properly sorted. */
- assert (status == 0 || status == SORT_FAILURE);
+
exit (status);
}
@@ -2240,7 +2239,7 @@ main (int argc, char **argv)
atexit (cleanup);
- exit_failure = SORT_FAILURE;
+ initialize_exit_failure (SORT_FAILURE);
atexit (close_stdout);
hard_LC_COLLATE = hard_locale (LC_COLLATE);
@@ -2269,9 +2268,6 @@ main (int argc, char **argv)
have_read_stdin = false;
inittables ();
-
- /* Change the way library functions fail. */
- exit_failure = SORT_FAILURE;
#ifdef SA_NOCLDSTOP
{
Index: src/split.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/split.c,v
retrieving revision 1.96
diff -p -u -r1.96 split.c
--- src/split.c 4 Nov 2003 06:25:45 -0000 1.96
+++ src/split.c 20 Jan 2004 00:21:35 -0000
@@ -1,5 +1,5 @@
/* split.c -- split a file into pieces.
- Copyright (C) 88, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 88, 91, 1995-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
@@ -92,7 +92,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
@@ -128,7 +128,7 @@ SIZE may have a multiplier suffix: b for
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Compute the next sequential output file name and store it into the
Index: src/stat.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/stat.c,v
retrieving revision 1.60
diff -p -u -r1.60 stat.c
--- src/stat.c 8 Jan 2004 14:28:44 -0000 1.60
+++ src/stat.c 20 Jan 2004 00:22:16 -0000
@@ -687,7 +687,7 @@ do_stat (char const *filename, int follo
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/stty.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/stty.c,v
retrieving revision 1.122
diff -p -u -r1.122 stty.c
--- src/stty.c 5 Nov 2003 03:53:19 -0000 1.122
+++ src/stty.c 20 Jan 2004 00:22:33 -0000
@@ -1,5 +1,5 @@
/* stty -- change and print terminal line settings
- 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
@@ -481,7 +481,7 @@ wrapf (const char *message,...)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -776,7 +776,7 @@ main (int argc, char **argv)
case 'F':
if (file_name)
- error (2, 0, _("only one device may be specified"));
+ error (EXIT_FAILURE, 0, _("only one device may be specified"));
file_name = optarg;
break;
@@ -870,13 +870,14 @@ main (int argc, char **argv)
/* Specifying both -a and -g gets an error. */
if (verbose_output && recoverable_output)
- error (2, 0,
+ error (EXIT_FAILURE, 0,
_("the options for verbose and stty-readable output styles are\n\
mutually exclusive"));
/* Specifying any other arguments with -a or -g gets an error. */
if (!noargs && (verbose_output || recoverable_output))
- error (2, 0, _("when specifying an output style, modes may not be set"));
+ error (EXIT_FAILURE, 0,
+ _("when specifying an output style, modes may not be set"));
/* FIXME: it'd be better not to open the file until we've verified
that all arguments are valid. Otherwise, we could end up doing
Index: src/su.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/su.c,v
retrieving revision 1.83
diff -p -u -r1.83 su.c
--- src/su.c 18 Oct 2003 10:05:47 -0000 1.83
+++ src/su.c 20 Jan 2004 00:22:46 -0000
@@ -1,5 +1,5 @@
/* su for GNU. Run a shell with substitute user and group IDs.
- Copyright (C) 1992-2003 Free Software Foundation, Inc.
+ Copyright (C) 1992-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
@@ -346,13 +346,13 @@ change_identity (const struct passwd *pw
#ifdef HAVE_INITGROUPS
errno = 0;
if (initgroups (pw->pw_name, pw->pw_gid) == -1)
- error (EXIT_FAILURE, errno, _("cannot set groups"));
+ error (EXIT_FAIL, errno, _("cannot set groups"));
endgrent ();
#endif
if (setgid (pw->pw_gid))
- error (EXIT_FAILURE, errno, _("cannot set group id"));
+ error (EXIT_FAIL, errno, _("cannot set group id"));
if (setuid (pw->pw_uid))
- error (EXIT_FAILURE, errno, _("cannot set user id"));
+ error (EXIT_FAIL, errno, _("cannot set user id"));
}
/* Run SHELL, or DEFAULT_SHELL if SHELL is empty.
@@ -398,7 +398,7 @@ run_shell (const char *shell, const char
execv (shell, (char **) args);
{
- int exit_status = (errno == ENOENT ? 127 : 126);
+ int exit_status = (errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE);
error (0, errno, "%s", shell);
exit (exit_status);
}
@@ -428,7 +428,7 @@ restricted_shell (const char *shell)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -472,6 +472,7 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ initialize_exit_failure (EXIT_FAIL);
atexit (close_stdout);
fast_startup = 0;
@@ -511,7 +512,7 @@ main (int argc, char **argv)
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (EXIT_FAILURE);
+ usage (EXIT_FAIL);
}
}
@@ -527,7 +528,7 @@ main (int argc, char **argv)
pw = getpwnam (new_user);
if (pw == 0)
- error (EXIT_FAILURE, 0, _("user %s does not exist"), new_user);
+ error (EXIT_FAIL, 0, _("user %s does not exist"), new_user);
endpwent ();
/* Make sure pw->pw_shell is non-NULL. It may be NULL when NEW_USER
@@ -550,7 +551,7 @@ main (int argc, char **argv)
#ifdef SYSLOG_FAILURE
log_su (pw, 0);
#endif
- error (EXIT_FAILURE, 0, _("incorrect password"));
+ error (EXIT_FAIL, 0, _("incorrect password"));
}
#ifdef SYSLOG_SUCCESS
else
Index: src/sum.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/sum.c,v
retrieving revision 1.72
diff -p -u -r1.72 sum.c
--- src/sum.c 18 Oct 2003 10:05:47 -0000 1.72
+++ src/sum.c 20 Jan 2004 00:23:31 -0000
@@ -1,5 +1,5 @@
/* sum -- checksum and count the blocks in a file
- Copyright (C) 86, 89, 91, 1995-2002 Free Software Foundation, Inc.
+ Copyright (C) 86, 89, 91, 1995-2002, 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
@@ -51,7 +51,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
@@ -74,7 +74,7 @@ With no FILE, or when FILE is -, read st
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Calculate and print the rotated checksum and the size in 1K blocks
Index: src/sync.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/sync.c,v
retrieving revision 1.45
diff -p -u -r1.45 sync.c
--- src/sync.c 5 Nov 2003 03:53:19 -0000 1.45
+++ src/sync.c 20 Jan 2004 00:23:46 -0000
@@ -1,5 +1,5 @@
/* sync - update the super block
- Copyright (C) 1994-2003 Free Software Foundation, Inc.
+ Copyright (C) 1994-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
@@ -36,7 +36,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/system.h
===================================================================
RCS file: /home/meyering/coreutils/cu/src/system.h,v
retrieving revision 1.78
diff -p -u -r1.78 system.h
--- src/system.h 13 Jan 2004 00:00:39 -0000 1.78
+++ src/system.h 20 Jan 2004 05:29:47 -0000
@@ -148,6 +148,25 @@ extern int errno;
# define EXIT_SUCCESS 0
#endif
+/* Exit statuses for programs like 'env' that exec other programs.
+ EXIT_FAILURE might not be 1, so use EXIT_FAIL in such programs. */
+enum
+{
+ EXIT_FAIL = 1,
+ EXIT_CANNOT_INVOKE = 126,
+ EXIT_ENOENT = 127
+};
+
+#include "exitfail.h"
+
+/* Set exit_failure to STATUS if that's not the default already. */
+static inline void
+initialize_exit_failure (int status)
+{
+ if (status != EXIT_FAILURE)
+ exit_failure = status;
+}
+
#if HAVE_FCNTL_H
# include <fcntl.h>
#else
Index: src/tac.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tac.c,v
retrieving revision 1.108
diff -p -u -r1.108 tac.c
--- src/tac.c 4 Nov 2003 09:31:08 -0000 1.108
+++ src/tac.c 20 Jan 2004 00:24:31 -0000
@@ -1,5 +1,5 @@
/* tac - concatenate and print files in reverse
- Copyright (C) 1988-1991, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 1988-1991, 1995-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
@@ -118,7 +118,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
@@ -144,7 +144,7 @@ Mandatory arguments to long options are
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Print the characters from START to PAST_END - 1.
Index: src/tail.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tail.c,v
retrieving revision 1.220
diff -p -u -r1.220 tail.c
--- src/tail.c 12 Jan 2004 09:41:29 -0000 1.220
+++ src/tail.c 20 Jan 2004 00:25:16 -0000
@@ -230,7 +230,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -303,7 +303,7 @@ recreated by some other program.\n\
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
static int
Index: src/tee.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tee.c,v
retrieving revision 1.70
diff -p -u -r1.70 tee.c
--- src/tee.c 4 Jan 2004 21:07:40 -0000 1.70
+++ src/tee.c 20 Jan 2004 00:25:51 -0000
@@ -1,5 +1,5 @@
/* tee - read from standard input and write to standard output and files.
- Copyright (C) 85,1990-2003 Free Software Foundation, Inc.
+ Copyright (C) 85,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
@@ -54,7 +54,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/test.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/test.c,v
retrieving revision 1.98
diff -p -u -r1.98 test.c
--- src/test.c 5 Nov 2003 03:53:19 -0000 1.98
+++ src/test.c 20 Jan 2004 05:29:49 -0000
@@ -2,7 +2,7 @@
/* Modified to run with the GNU shell by bfox. */
-/* Copyright (C) 1987-2003 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -42,7 +42,6 @@
#include "system.h"
#include "error.h"
-#include "exitfail.h"
#include "euidaccess.h"
#ifndef _POSIX_VERSION
@@ -968,7 +967,7 @@ posixtest (int nargs)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -1085,7 +1084,7 @@ main (int margc, char **margv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- exit_failure = TEST_FAILURE;
+ initialize_exit_failure (TEST_FAILURE);
atexit (close_stdout);
#endif /* TEST_STANDALONE */
Index: src/touch.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/touch.c,v
retrieving revision 1.118
diff -p -u -r1.118 touch.c
--- src/touch.c 15 Jan 2004 18:44:04 -0000 1.118
+++ src/touch.c 20 Jan 2004 00:26:26 -0000
@@ -240,7 +240,7 @@ touch (const char *file)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -433,7 +433,7 @@ main (int argc, char **argv)
}
for (; optind < argc; ++optind)
- err += touch (argv[optind]);
+ err |= touch (argv[optind]);
- exit (err != 0);
+ exit (err == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
}
Index: src/tr.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tr.c,v
retrieving revision 1.125
diff -p -u -r1.125 tr.c
--- src/tr.c 5 Nov 2003 03:49:29 -0000 1.125
+++ src/tr.c 20 Jan 2004 00:26:39 -0000
@@ -1,5 +1,5 @@
/* tr -- a filter to translate characters
- Copyright (C) 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 91, 1995-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
@@ -312,7 +312,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -388,7 +388,7 @@ translation or deletion.\n\
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Return nonzero if the character C is a member of the
@@ -1822,7 +1822,7 @@ main (int argc, char **argv)
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
default:
- usage (2);
+ usage (EXIT_FAILURE);
break;
}
}
@@ -1840,7 +1840,7 @@ main (int argc, char **argv)
if (non_option_args > 2)
{
error (0, 0, _("too many arguments"));
- usage (2);
+ usage (EXIT_FAILURE);
}
if (!delete && !squeeze_repeats && non_option_args != 2)
Index: src/tsort.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tsort.c,v
retrieving revision 1.38
diff -p -u -r1.38 tsort.c
--- src/tsort.c 5 Nov 2003 03:53:19 -0000 1.38
+++ src/tsort.c 20 Jan 2004 00:27:29 -0000
@@ -1,5 +1,5 @@
/* tsort - topological sort.
- Copyright (C) 1998-2003 Free Software Foundation, Inc.
+ Copyright (C) 1998-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
@@ -65,7 +65,7 @@ char *program_name;
/* Nonzero if any of the input files are the standard input. */
static int have_read_stdin;
-/* The error code to return to the system. */
+/* Nonzero if a nonfatal error has occurred. */
static int exit_status;
/* The head of the sorted list. */
@@ -88,7 +88,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -104,7 +104,7 @@ With no FILE, or when FILE is -, read st
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Create a new item/node for STR. */
Index: src/tty.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/tty.c,v
retrieving revision 1.53
diff -p -u -r1.53 tty.c
--- src/tty.c 18 Oct 2003 10:05:47 -0000 1.53
+++ src/tty.c 20 Jan 2004 05:29:49 -0000
@@ -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);
}
Index: src/uname.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/uname.c,v
retrieving revision 1.56
diff -p -u -r1.56 uname.c
--- src/uname.c 18 Oct 2003 10:05:47 -0000 1.56
+++ src/uname.c 20 Jan 2004 00:28:37 -0000
@@ -1,7 +1,7 @@
/* uname -- print system information
- Copyright 1989, 1992, 1993, 1996, 1997, 1999, 2000, 2001, 2002, 2003 Free
- Software Foundation, Inc.
+ Copyright 1989, 1992, 1993, 1996, 1997, 1999, 2000, 2001, 2002,
+ 2003, 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
@@ -101,7 +101,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/unexpand.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/unexpand.c,v
retrieving revision 1.79
diff -p -u -r1.79 unexpand.c
--- src/unexpand.c 4 Jan 2004 21:09:30 -0000 1.79
+++ src/unexpand.c 20 Jan 2004 00:29:02 -0000
@@ -1,5 +1,5 @@
/* unexpand - convert spaces to tabs
- Copyright (C) 89, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 89, 91, 1995-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
@@ -369,7 +369,7 @@ unexpand (void)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
@@ -396,7 +396,7 @@ Mandatory arguments to long options are
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
int
Index: src/uniq.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/uniq.c,v
retrieving revision 1.109
diff -p -u -r1.109 uniq.c
--- src/uniq.c 18 Oct 2003 10:05:47 -0000 1.109
+++ src/uniq.c 20 Jan 2004 06:06:18 -0000
@@ -1,5 +1,5 @@
/* uniq -- remove duplicate lines from a sorted file
- Copyright (C) 86, 91, 1995-2003, Free Software Foundation, Inc.
+ Copyright (C) 86, 91, 1995-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
@@ -126,7 +126,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
@@ -168,7 +168,7 @@ Fields are skipped before chars.\n\
"), stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* Convert OPT to size_t, reporting an error using MSGID if it does
Index: src/unlink.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/unlink.c,v
retrieving revision 1.10
diff -p -u -r1.10 unlink.c
--- src/unlink.c 5 Nov 2003 03:53:19 -0000 1.10
+++ src/unlink.c 20 Jan 2004 00:29:26 -0000
@@ -1,5 +1,5 @@
/* unlink utility for GNU.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 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
@@ -43,7 +43,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/uptime.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/uptime.c,v
retrieving revision 1.38
diff -p -u -r1.38 uptime.c
--- src/uptime.c 5 Nov 2003 03:53:19 -0000 1.38
+++ src/uptime.c 20 Jan 2004 00:29:37 -0000
@@ -1,5 +1,5 @@
/* GNU's uptime.
- Copyright (C) 1992-2002 Free Software Foundation, Inc.
+ Copyright (C) 1992-2002, 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
@@ -182,7 +182,7 @@ uptime (const char *filename)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/users.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/users.c,v
retrieving revision 1.32
diff -p -u -r1.32 users.c
--- src/users.c 5 Nov 2003 03:53:19 -0000 1.32
+++ src/users.c 20 Jan 2004 00:29:45 -0000
@@ -1,5 +1,5 @@
/* GNU's users.
- Copyright (C) 1992-2003 Free Software Foundation, Inc.
+ Copyright (C) 1992-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
@@ -111,7 +111,7 @@ users (const char *filename)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/wc.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/wc.c,v
retrieving revision 1.97
diff -p -u -r1.97 wc.c
--- src/wc.c 6 Nov 2003 09:28:13 -0000 1.97
+++ src/wc.c 20 Jan 2004 00:29:53 -0000
@@ -1,5 +1,5 @@
/* wc - print the number of bytes, words, and lines in files
- Copyright (C) 85, 91, 1995-2003 Free Software Foundation, Inc.
+ Copyright (C) 85, 91, 1995-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
@@ -127,7 +127,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
@@ -152,7 +152,7 @@ read standard input.\n\
fputs (VERSION_OPTION_DESCRIPTION, stdout);
printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
- exit (status == 0 ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit (status);
}
/* FILE is the name of the file (or NULL for standard input)
Index: src/who.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/who.c,v
retrieving revision 1.89
diff -p -u -r1.89 who.c
--- src/who.c 6 Nov 2003 09:28:40 -0000 1.89
+++ src/who.c 20 Jan 2004 00:30:00 -0000
@@ -1,5 +1,5 @@
/* GNU's who.
- Copyright (C) 1992-2003 Free Software Foundation, Inc.
+ Copyright (C) 1992-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
@@ -612,7 +612,7 @@ who (const char *filename)
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/whoami.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/whoami.c,v
retrieving revision 1.40
diff -p -u -r1.40 whoami.c
--- src/whoami.c 5 Nov 2003 03:53:19 -0000 1.40
+++ src/whoami.c 20 Jan 2004 00:30:17 -0000
@@ -1,5 +1,7 @@
/* whoami -- print effective userid
- Copyright (C) 89,90, 1991-1997, 1999-2002 Free Software Foundation, Inc.
+
+ Copyright (C) 89,90, 1991-1997, 1999-2002, 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
@@ -43,7 +45,7 @@ static struct option const long_options[
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: src/yes.c
===================================================================
RCS file: /home/meyering/coreutils/cu/src/yes.c,v
retrieving revision 1.52
diff -p -u -r1.52 yes.c
--- src/yes.c 5 Nov 2003 03:53:19 -0000 1.52
+++ src/yes.c 20 Jan 2004 00:30:25 -0000
@@ -1,5 +1,5 @@
/* yes - output a string repeatedly until killed
- Copyright (C) 1991-1997, 1999-2003 Free Software Foundation, Inc.
+ Copyright (C) 1991-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
@@ -38,7 +38,7 @@ char *program_name;
void
usage (int status)
{
- if (status != 0)
+ if (status != EXIT_SUCCESS)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
else
Index: tests/help-version
===================================================================
RCS file: /home/meyering/coreutils/cu/tests/help-version,v
retrieving revision 1.11
diff -p -u -r1.11 help-version
--- tests/help-version 27 Nov 2003 08:45:01 -0000 1.11
+++ tests/help-version 20 Jan 2004 05:52:30 -0000
@@ -4,7 +4,7 @@
test "$VERBOSE" = yes && set -x
-expected_failure_status_date=2
+expected_failure_status_nohup=127
expected_failure_status_printenv=2
expected_failure_status_tty=3
expected_failure_status_sort=2
- exit status patch for coreutils,
Paul Eggert <=