]> Savannah Git Hosting - gnulib.git/commitdiff
gen-header: port to BusyBox ‘sed’
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 1 Jan 2022 23:30:38 +0000 (15:30 -0800)
committerBruno Haible <bruno@clisp.org>
Wed, 31 Aug 2022 22:23:35 +0000 (00:23 +0200)
Problem reported by Tim Rühsen in:
https://lists.gnu.org/r/bug-gnulib/2022-01/msg00004.html
* modules/gen-header (SED_HEADER_NOEDIT): Replace instead of prepend.
(SED_HEADER_STDOUT, SED_HEADER_TO_AT_t): Adjust to that change.
Do not use ‘w foo’ twice in the same script, as BusyBox ‘sed’
mistakenly opens ‘foo’ for output twice, thus losing some output.

ChangeLog
modules/gen-header

index e2e2c11b2af4bed07845ed92a593d3b87de463f6..3eb87d7d644b7a18235c5af199718ac06c090cdd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-01-01  Paul Eggert  <eggert@cs.ucla.edu>
+
+       gen-header: port to BusyBox ‘sed’
+       Problem reported by Tim Rühsen in:
+       https://lists.gnu.org/r/bug-gnulib/2022-01/msg00004.html
+       * modules/gen-header (SED_HEADER_NOEDIT): Replace instead of prepend.
+       (SED_HEADER_STDOUT, SED_HEADER_TO_AT_t): Adjust to that change.
+       Do not use ‘w foo’ twice in the same script, as BusyBox ‘sed’
+       mistakenly opens ‘foo’ for output twice, thus losing some output.
+
 2022-01-01  Bruno Haible  <bruno@clisp.org>
 
        maint: Update copyright notices.
index ab1858d65f53a992a3cf7eb36d5016924063800e..feb711b5c673ce98e18648e38f561936bf6b9173 100644 (file)
@@ -11,24 +11,17 @@ Depends-on:
 configure.ac:
 
 Makefile.am:
-# In 'sed', prepend a "DO NOT EDIT" comment to the pattern space.
-SED_HEADER_NOEDIT = s,^,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */,
+# In 'sed', replace the pattern space with a "DO NOT EDIT" comment.
+SED_HEADER_NOEDIT = s,.*,/* DO NOT EDIT! GENERATED AUTOMATICALLY! */,
 
 # '$(SED_HEADER_STDOUT) -e "..."' runs 'sed' but first outputs "DO NOT EDIT".
-SED_HEADER_STDOUT = sed \
-  -e x \
-  -e '1$(SED_HEADER_NOEDIT)p' \
-  -e x
+SED_HEADER_STDOUT = sed -e 1h -e '1$(SED_HEADER_NOEDIT)' -e 1G
 
 # '$(SED_HEADER_TO_AT_t) FILE' copies FILE to $@-t, prepending a leading
 # "DO_NOT_EDIT".  Although this could be done more simply via:
 #      SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-t
-# the -n and 'w's avoid a fork+exec, at least when GNU Make is used.
-SED_HEADER_TO_AT_t = sed -n \
-  -e x \
-  -e '1$(SED_HEADER_NOEDIT)w $@-t' \
-  -e x \
-  -e 'w $@-t'
+# the -n and 'w' avoid a fork+exec, at least when GNU Make is used.
+SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) -n -e 'w $@-t'
 
 # Use $(gl_V_at) instead of $(AM_V_GEN) or $(AM_V_at) on a line that
 # is its recipe's first line if and only if @NMD@ lines are absent.