bug-gnulib
[Top][All Lists]
Advanced

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

[PATCH] consistently remove address@hidden before redirecting to it


From: Jim Meyering
Subject: [PATCH] consistently remove address@hidden before redirecting to it
Date: Fri, 21 Aug 2009 11:03:39 +0200

If I touch lib/glob.in.h and create an unwritable named lib/glob.h-t,
that causes all subsequent build attempts to fail, because redirecting
to an unreadable file fails.  (that actually happens if you happen to
experiment with an overly restrictive umask)

There are several modules that have this problem:

    $ grep -l 'address@hidden' *|xargs grep -L 'rm -f address@hidden $@'
    alloca-opt
    argz
    configmake
    fnmatch
    getopt-posix
    glob
    poll
    posix_spawnp-tests
    sys_socket
    sysexits

The usual idiom is to remove both $@ and address@hidden first,
generate address@hidden, and if successful, rename that to $@, atomically.
Here's one that does it right:

unistd.h: unistd.in.h
        rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''HAVE_UNISTD_H''@|$(HAVE_UNISTD_H)|g' \
          ...
        } > address@hidden
        mv address@hidden $@

However, the above modules lacked the key initial "rm -f ..." statement.
This patch fixes that by adding the command in all but configmake,
which is slightly special in that it performs the move-if-changed
trick to avoid updating the target's timestamp when there is no change.
In its case, I left it unmodified, with this line:

        rm -f address@hidden

There's also a slight inconsistency: some modules use
"mv -f address@hidden $@", while others use no -f option: "mv address@hidden 
$@".
I haven't addressed that, for now, which means the added rm -f
statements can be seen as removing $@ unnecessarily, when
the final move-into-place command uses "mv -f".

>From bd8cfad4eb68e459d9fd24144df7a106765f8c09 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 21 Aug 2009 10:56:58 +0200
Subject: [PATCH] consistently remove address@hidden before redirecting to it

* modules/argz: Remove address@hidden and $@ before redirecting to the former.
* modules/alloca-opt: Likewise.
* modules/byteswap: Likewise.
* modules/fnmatch: Likewise.
* modules/getopt-posix: Likewise.
* modules/glob: Likewise.
* modules/poll: Likewise.
* modules/posix_spawnp-tests: Likewise.
* modules/sys_socket: Likewise.
* modules/sysexits: Likewise.
---
 ChangeLog                  |   14 ++++++++++++++
 modules/alloca-opt         |    1 +
 modules/argz               |    1 +
 modules/byteswap           |    1 +
 modules/fnmatch            |    1 +
 modules/getopt-posix       |    1 +
 modules/glob               |    1 +
 modules/poll               |    1 +
 modules/posix_spawnp-tests |    2 ++
 modules/sys_socket         |    1 +
 modules/sysexits           |    1 +
 11 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 580212c..8210003 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2009-08-21  Jim Meyering  <address@hidden>
+
+       consistently remove address@hidden before redirecting to it
+       * modules/argz: Remove address@hidden and $@ before redirecting to the 
former.
+       * modules/alloca-opt: Likewise.
+       * modules/byteswap: Likewise.
+       * modules/fnmatch: Likewise.
+       * modules/getopt-posix: Likewise.
+       * modules/glob: Likewise.
+       * modules/poll: Likewise.
+       * modules/posix_spawnp-tests: Likewise.
+       * modules/sys_socket: Likewise.
+       * modules/sysexits: Likewise.
+
 2009-08-21  Eric Blake  <address@hidden>

        popen: simplify access to original popen
diff --git a/modules/alloca-opt b/modules/alloca-opt
index 248b486..e132ab8 100644
--- a/modules/alloca-opt
+++ b/modules/alloca-opt
@@ -18,6 +18,7 @@ BUILT_SOURCES += $(ALLOCA_H)
 # We need the following in order to create <alloca.h> when the system
 # doesn't have one that works with the given compiler.
 alloca.h: alloca.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          cat $(srcdir)/alloca.in.h; \
        } > address@hidden
diff --git a/modules/argz b/modules/argz
index 7ef73d5..7c95859 100644
--- a/modules/argz
+++ b/modules/argz
@@ -23,6 +23,7 @@ BUILT_SOURCES += $(ARGZ_H)
 # We need the following in order to create <argz.h> when the system
 # doesn't have one that works with the given compiler.
 argz.h: argz.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          cat $(srcdir)/argz.in.h; \
        } > address@hidden
diff --git a/modules/byteswap b/modules/byteswap
index 320e8a4..c5057bb 100644
--- a/modules/byteswap
+++ b/modules/byteswap
@@ -16,6 +16,7 @@ BUILT_SOURCES += $(BYTESWAP_H)
 # We need the following in order to create <byteswap.h> when the system
 # doesn't have one.
 byteswap.h: byteswap.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          cat $(srcdir)/byteswap.in.h; \
        } > address@hidden
diff --git a/modules/fnmatch b/modules/fnmatch
index 441d5d3..64d3cd9 100644
--- a/modules/fnmatch
+++ b/modules/fnmatch
@@ -28,6 +28,7 @@ BUILT_SOURCES += $(FNMATCH_H)
 # We need the following in order to create <fnmatch.h> when the system
 # doesn't have one that supports the required API.
 fnmatch.h: fnmatch.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          cat $(srcdir)/fnmatch.in.h; \
        } > address@hidden
diff --git a/modules/getopt-posix b/modules/getopt-posix
index b36ed1e..6b20f15 100644
--- a/modules/getopt-posix
+++ b/modules/getopt-posix
@@ -22,6 +22,7 @@ BUILT_SOURCES += $(GETOPT_H)
 # We need the following in order to create <getopt.h> when the system
 # doesn't have one that works with the given compiler.
 getopt.h: getopt.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          cat $(srcdir)/getopt.in.h; \
        } > address@hidden
diff --git a/modules/glob b/modules/glob
index b765be7..bf7af7c 100644
--- a/modules/glob
+++ b/modules/glob
@@ -32,6 +32,7 @@ BUILT_SOURCES += $(GLOB_H)
 # We need the following in order to create <glob.h> when the system
 # doesn't have one that works with the given compiler.
 glob.h: glob.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''HAVE_SYS_CDEFS_H''@|$(HAVE_SYS_CDEFS_H)|g' \
              < $(srcdir)/glob.in.h; \
diff --git a/modules/poll b/modules/poll
index b83cb2b..612189b 100644
--- a/modules/poll
+++ b/modules/poll
@@ -22,6 +22,7 @@ BUILT_SOURCES += $(POLL_H)
 # We need the following in order to create <poll.h> when the system
 # doesn't have one.
 poll.h: poll.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          cat $(srcdir)/poll.in.h; \
        } > address@hidden
diff --git a/modules/posix_spawnp-tests b/modules/posix_spawnp-tests
index f8c7233..61ea8e4 100644
--- a/modules/posix_spawnp-tests
+++ b/modules/posix_spawnp-tests
@@ -36,12 +36,14 @@ check_PROGRAMS += test-posix_spawn1 test-posix_spawn2

 BUILT_SOURCES += test-posix_spawn1.sh
 test-posix_spawn1.sh: test-posix_spawn1.in.sh
+       rm -f address@hidden $@
        cp $(srcdir)/test-posix_spawn1.in.sh address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += test-posix_spawn1.sh test-posix_spawn1.sh-t

 BUILT_SOURCES += test-posix_spawn2.sh
 test-posix_spawn2.sh: test-posix_spawn2.in.sh
+       rm -f address@hidden $@
        cp $(srcdir)/test-posix_spawn2.in.sh address@hidden
        mv address@hidden $@
 MOSTLYCLEANFILES += test-posix_spawn2.sh test-posix_spawn2.sh-t
diff --git a/modules/sys_socket b/modules/sys_socket
index e07dd05..37e9e45 100644
--- a/modules/sys_socket
+++ b/modules/sys_socket
@@ -23,6 +23,7 @@ BUILT_SOURCES += $(SYS_SOCKET_H)
 # doesn't have one that works with the given compiler.
 sys/socket.h: sys_socket.in.h
        @MKDIR_P@ sys
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
diff --git a/modules/sysexits b/modules/sysexits
index 1f84603..99bcdd3 100644
--- a/modules/sysexits
+++ b/modules/sysexits
@@ -17,6 +17,7 @@ BUILT_SOURCES += $(SYSEXITS_H)
 # We need the following in order to create <sysexits.h> when the system
 # doesn't have one that works with the given compiler.
 sysexits.h: sysexits.in.h
+       rm -f address@hidden $@
        { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
          sed -e 's|@''HAVE_SYSEXITS_H''@|$(HAVE_SYSEXITS_H)|g' \
              -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
--
1.6.4.378.g88f2f




reply via email to

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