bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch] VPATH-style build of CVS coreutils (generated false.c)


From: Paul Eggert
Subject: Re: [patch] VPATH-style build of CVS coreutils (generated false.c)
Date: Mon, 18 Jul 2005 01:06:44 -0700
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)

James Youngman <address@hidden> writes:

> +defaulttarget: all
> +
> +$(top_srcdir)/src/false.c: ../src/false.c
> +     /bin/cp ../src/false.c $(top_srcdir)/src/false.c

Thanks for reporting the problem, but I agree that's an unpleasant
hack.  I installed the following instead: it's a longer patch, but I
hope a cleaner one.

2005-07-18  Paul Eggert  <address@hidden>

        Fix a problem noted by James Youngman: VPATH-style builds don't
        work because of po file problems.
        * doc/coreutils.texi (false invocation):
        Mention that false is often built-in, and that it exits
        with status >1 on some hosts.
        (true invocation): Remove now-incorrect "non-POSIX mode" reference.
        * src/Makefile.am (BUILT_SOURCES): Remove false.c.
        (false.c): Remove; it's now a source file.
        * src/false.c: New file.
        * src/true.c (EXIT_STATUS): New macro.
        (PROGRAM_NAME, usage): Behave like "false" if EXIT_STATUS indicates.
        (usage): Remove "These option names may not be abbreviated."

--- /dev/null   2005-06-27 15:40:05.000000000 -0700
+++ src/false.c 2005-07-17 23:41:48.000000000 -0700
@@ -0,0 +1,2 @@
+#define EXIT_STATUS EXIT_FAILURE
+#include "true.c"
Index: doc/coreutils.texi
===================================================================
RCS file: /fetish/cu/doc/coreutils.texi,v
retrieving revision 1.272
diff -p -u -r1.272 coreutils.texi
--- doc/coreutils.texi  15 Jul 2005 21:54:56 -0000      1.272
+++ doc/coreutils.texi  18 Jul 2005 07:44:37 -0000
@@ -9577,6 +9577,9 @@ pipeline.
 @command{false} does nothing except return an exit status of 1, meaning
 @dfn{failure}.  It can be used as a place holder in shell scripts
 where an unsuccessful command is needed.
+In most modern shells, @command{false} is a built-in command, so when
+you use @samp{false} in a script, you're probably using the built-in
+command, not the one documented here.
 
 @command{false} honors the @option{--help} and @option{--version} options.
 
@@ -9588,6 +9591,10 @@ Note that @command{false} (unlike all ot
 exits unsuccessfully, even when invoked with
 @option{--help} or @option{--version}.
 
+Portable programs should not assume that the exit status of
address@hidden is 1, as it is greater than 1 on some
address@hidden hosts.
+
 
 @node true invocation
 @section @command{true}: Do nothing, successfully
@@ -9609,8 +9616,8 @@ command, not the one documented here.
 @command{true} honors the @option{--help} and @option{--version} options.
 
 Note, however, that it is possible to cause @command{true}
-to exit with nonzero status: when invoked in address@hidden mode,
-with the @option{--help} or @option{--version} option, and with standard
+to exit with nonzero status: with the @option{--help} or @option{--version}
+option, and with standard
 output already closed or redirected to a file that evokes an I/O error.
 For example, using a Bourne-compatible shell:
 
Index: src/Makefile.am
===================================================================
RCS file: /fetish/cu/src/Makefile.am,v
retrieving revision 1.57
diff -p -u -r1.57 Makefile.am
--- src/Makefile.am     14 Jul 2005 00:03:08 -0000      1.57
+++ src/Makefile.am     18 Jul 2005 07:44:37 -0000
@@ -211,17 +211,6 @@ wheel.h: wheel-gen.pl Makefile.am
 # Tell automake to exempt then from that installcheck test.
 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
 
-BUILT_SOURCES += false.c
-false.c: true.c
-       @rm -f $@ address@hidden
-       sed \
-         -e s/true/false/g \
-         -e s/success/failure/g \
-         -e 's/(EXIT_SUCCESS)/(EXIT_FAILURE)/g' \
-         $(srcdir)/true.c > address@hidden
-       @chmod a-w address@hidden
-       mv address@hidden $@
-
 BUILT_SOURCES += fs.h
 fs.h: stat.c extract-magic
        rm -f $@
Index: src/true.c
===================================================================
RCS file: /fetish/cu/src/true.c,v
retrieving revision 1.24
diff -p -u -r1.24 true.c
--- src/true.c  14 May 2005 07:58:37 -0000      1.24
+++ src/true.c  18 Jul 2005 07:44:38 -0000
@@ -20,7 +20,17 @@
 #include <sys/types.h>
 #include "system.h"
 
-#define PROGRAM_NAME "true"
+/* Act like "true" by default; false.c overrides this.  */
+#ifndef EXIT_STATUS
+# define EXIT_STATUS EXIT_SUCCESS
+#endif
+
+#if EXIT_STATUS == EXIT_SUCCESS
+# define PROGRAM_NAME "true"
+#else
+# define PROGRAM_NAME "false"
+#endif
+
 #define AUTHORS "Jim Meyering"
 
 /* The name this program was run with. */
@@ -34,13 +44,10 @@ Usage: %s [ignored command line argument
   or:  %s OPTION\n\
 "),
          program_name, program_name);
-  fputs (_("\
-Exit with a status code indicating success.\n\
-\n\
-These option names may not be abbreviated.\n\
-\n\
-"),
-        stdout);
+  printf ("%s\n\n",
+         _(EXIT_STATUS == EXIT_SUCCESS
+           ? "Exit with a status code indicating success."
+           : "Exit with a status code indicating failure."));
   fputs (HELP_OPTION_DESCRIPTION, stdout);
   fputs (VERSION_OPTION_DESCRIPTION, stdout);
   printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
@@ -64,12 +71,12 @@ main (int argc, char **argv)
   if (argc == 2)
     {
       if (STREQ (argv[1], "--help"))
-       usage (EXIT_SUCCESS);
+       usage (EXIT_STATUS);
 
       if (STREQ (argv[1], "--version"))
        version_etc (stdout, PROGRAM_NAME, GNU_PACKAGE, VERSION, AUTHORS,
                     (char *) NULL);
     }
 
-  exit (EXIT_SUCCESS);
+  exit (EXIT_STATUS);
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]