Paul,

I suggest the attached patch. Objections?

Bruno
From 4e30d9715e44f2aade3927e762a4b1fee340962e Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sat, 1 Jan 2022 21:12:21 +0100
Subject: [PATCH] gen-header: Fix major bug on Alpine Linux (regression
 2021-12-25).
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Reported by Tim Rühsen <tim.rueh...@gmx.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2022-01/msg00004.html>.

* modules/gen-header (Makefile.am): Define SED_HEADER_TO_AT_t without an
optimization that does not work with 'sed' from BusyBox.
---
 ChangeLog          |  8 ++++++++
 modules/gen-header | 12 ++++--------
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 21390af8f..9337c8830 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-01-01  Bruno Haible  <br...@clisp.org>
+
+	gen-header: Fix major bug on Alpine Linux (regression 2021-12-25).
+	Reported by Tim Rühsen <tim.rueh...@gmx.de> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2022-01/msg00004.html>.
+	* modules/gen-header (Makefile.am): Define SED_HEADER_TO_AT_t without an
+	optimization that does not work with 'sed' from BusyBox.
+
 2022-01-01  Bruno Haible  <br...@clisp.org>
 
 	striconveh: Support an error handler that produces a Unicode U+FFFD.
diff --git a/modules/gen-header b/modules/gen-header
index ab1858d65..05a1480d6 100644
--- a/modules/gen-header
+++ b/modules/gen-header
@@ -21,14 +21,10 @@ SED_HEADER_STDOUT = sed \
   -e x
 
 # '$(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'
+# "DO_NOT_EDIT".
+# Beware of optimizations that use 'w' to avoid a fork+exec; such optimizations
+# don't work on Alpine Linux (which has 'sed' from BusyBox).
+SED_HEADER_TO_AT_t = $(SED_HEADER_STDOUT) > $@-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.
-- 
2.25.1

Reply via email to