These two patches fix test suite failures seen on OpenBSD and Solaris.

2025-08-11  Bruno Haible  <br...@clisp.org>

        nlcanon tests: Fix test failure on Solaris.
        * tests/test-nlcanon.sh: Handle the --no-reexec option (from init.sh).

2025-08-11  Bruno Haible  <br...@clisp.org>

        nlcanon: Make it work on OpenBSD.
        * build-aux/nlcanon.sh.in (sed_convert_crlf): New variable. Use it
        instead of a sed script that contains '\r'.

>From 0e50f885cd26e42bdd74a10b962029c8b0a6e80d Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 11 Aug 2025 11:51:43 +0200
Subject: [PATCH 1/2] nlcanon: Make it work on OpenBSD.

* build-aux/nlcanon.sh.in (sed_convert_crlf): New variable. Use it
instead of a sed script that contains '\r'.
---
 ChangeLog               |  6 ++++++
 build-aux/nlcanon.sh.in | 10 +++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5173498a3a..7a62d7129b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2025-08-11  Bruno Haible  <br...@clisp.org>
+
+	nlcanon: Make it work on OpenBSD.
+	* build-aux/nlcanon.sh.in (sed_convert_crlf): New variable. Use it
+	instead of a sed script that contains '\r'.
+
 2025-08-10  Bruno Haible  <br...@clisp.org>
 
 	Use standard way of including <config.h>.
diff --git a/build-aux/nlcanon.sh.in b/build-aux/nlcanon.sh.in
index d5373f0b6c..d43c13b2fc 100644
--- a/build-aux/nlcanon.sh.in
+++ b/build-aux/nlcanon.sh.in
@@ -110,16 +110,20 @@ then
   trap 'exit_status=$?; func_cleanup_tmpfiles; exit $exit_status' EXIT
   exitcode_file="$tmp/exit"
 
+  # Need to use printf, because OpenBSD and Solaris 'sed' don't interpret \r
+  # as an escape sequence.
+  sed_convert_crlf='s/'`printf '\r'`'$//'
+
   # This is not a program. This is art. :D)
   case "$streams" in
     stdout)
-      { "$@"; echo "$?" > "$exitcode_file"; } | { sed -e 's/\r$//' 2>/dev/null; }
+      { "$@"; echo "$?" > "$exitcode_file"; } | { sed -e "$sed_convert_crlf" 2>/dev/null; }
       ;;
     stderr)
-      { { "$@" 2>&1 1>&3; echo "$?" > "$exitcode_file"; } | { sed -e 's/\r$//' 2>/dev/null; }; } 3>&1 1>&2
+      { { "$@" 2>&1 1>&3; echo "$?" > "$exitcode_file"; } | { sed -e "$sed_convert_crlf" 2>/dev/null; }; } 3>&1 1>&2
       ;;
     *) # both
-      { { "$@" 2>&1 1>&3; echo "$?" > "$exitcode_file"; } | { sed -e 's/\r$//' 2>/dev/null; }; } 3>&1 1>&2 | { sed -e 's/\r$//' 2>/dev/null; }
+      { { "$@" 2>&1 1>&3; echo "$?" > "$exitcode_file"; } | { sed -e "$sed_convert_crlf" 2>/dev/null; }; } 3>&1 1>&2 | { sed -e "$sed_convert_crlf" 2>/dev/null; }
       ;;
   esac
   exit `cat "$exitcode_file"`
-- 
2.50.1

>From b65a8d11a79bd72224deb06cf379bcbbd713fe36 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Mon, 11 Aug 2025 12:04:17 +0200
Subject: [PATCH 2/2] nlcanon tests: Fix test failure on Solaris.

* tests/test-nlcanon.sh: Handle the --no-reexec option (from init.sh).
---
 ChangeLog             |  5 +++++
 tests/test-nlcanon.sh | 12 ++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a62d7129b..0a44bca695 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2025-08-11  Bruno Haible  <br...@clisp.org>
+
+	nlcanon tests: Fix test failure on Solaris.
+	* tests/test-nlcanon.sh: Handle the --no-reexec option (from init.sh).
+
 2025-08-11  Bruno Haible  <br...@clisp.org>
 
 	nlcanon: Make it work on OpenBSD.
diff --git a/tests/test-nlcanon.sh b/tests/test-nlcanon.sh
index ddcfc1cd9f..9ef2c49c8e 100755
--- a/tests/test-nlcanon.sh
+++ b/tests/test-nlcanon.sh
@@ -1,11 +1,6 @@
 #!/bin/sh
 
-if test $# != 0; then
-  # Callee.
-  printf 'stdout-contents\r\n'
-  printf 'stderr-contents\r\n' 1>&2
-  exit $1
-else
+if test $# = 0 || { test $# = 1 && test "x$1" = "x--no-reexec"; }; then
   # Unit test.
   . "${srcdir=.}/init.sh"; path_prepend_ .
 
@@ -64,4 +59,9 @@ else
   test $? != 0 || Exit 37
 
   Exit 0
+else
+  # Callee.
+  printf 'stdout-contents\r\n'
+  printf 'stderr-contents\r\n' 1>&2
+  exit $1
 fi
-- 
2.50.1

Reply via email to