gbranden pushed a commit to branch master
in repository groff.

commit 5f9c6a0329bbad84505538192851feb501e88c19
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Mar 30 21:46:04 2025 -0500

    [nroff]: Use a good shell if one is available.
    
    Now that our "configure" script searches for a shell that is at least
    minimally competent, and an Automake macro to expand its name, use it in
    the "nroff" shell script.  This change doesn't obviate the need for
    run-time checks for features that we rely upon but which buggy shells
    mis-implement; we _search_ for a good shell, but an unsatisfactory
    "/bin/sh" might be all we find.  Also, we don't rely on the semantics of
    an empty interpreter name (`#!` followed by a newline), because some of
    our scripts need to invoke a subshell by name: 'test `sh -c "echo foo"`
    && status=good' works; 'test ` -c "echo foo"` && status=good' does not.
    
    * src/roff/nroff/nroff.sh: Update shebang line to use macro.
    * src/roff/nroff/nroff.am (nroff): Perform macro substitution.
---
 ChangeLog               | 17 +++++++++++++++++
 src/roff/nroff/nroff.am |  3 ++-
 src/roff/nroff/nroff.sh |  4 ++--
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9bc5b62b8..aa8df6ee9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2025-03-30  G. Branden Robinson <[email protected]>
+
+       [nroff]: Now that our "configure" script searches for a shell
+       that is at least minimally competent, and an Automake macro to
+       expand its name, use it in the "nroff" shell script.  This
+       change doesn't obviate the need for run-time checks for features
+       that we rely upon but which buggy shells mis-implement; we
+       _search_ for a good shell, but an unsatisfactory "/bin/sh" might
+       be all we find.  Also, we don't rely on the semantics of an
+       empty interpreter name (`#!` followed by a newline), because
+       some of our scripts need to invoke a subshell by name: 'test `sh
+       -c "echo foo"` && status=good' works; 'test ` -c "echo foo"` &&
+       status=good' does not.
+
+       * src/roff/nroff/nroff.sh: Update shebang line to use macro.
+       * src/roff/nroff/nroff.am (nroff): Perform macro substitution.
+
 2025-03-30  G. Branden Robinson <[email protected]>
 
        * m4/groff.m4 (GROFF_PROG_SH): Search more aggressively for
diff --git a/src/roff/nroff/nroff.am b/src/roff/nroff/nroff.am
index 9642fd5d0..c8f7d58cd 100644
--- a/src/roff/nroff/nroff.am
+++ b/src/roff/nroff/nroff.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2020 Free Software Foundation, Inc.
+# Copyright (C) 2014-2025 Free Software Foundation, Inc.
 #
 # This file is part of groff.
 #
@@ -32,6 +32,7 @@ nroff: $(nroff_srcdir)/nroff.sh $(SH_DEPS_SED_SCRIPT)
        && sed -f $(SH_DEPS_SED_SCRIPT) \
               -e $(SH_SCRIPT_SED_CMD) \
               -e "s|[@]VERSION[@]|$(VERSION)|" \
+              -e "s|[@]POSIX_SHELL_PROG[@]|$(POSIX_SHELL_PROG)|g" \
               $(nroff_srcdir)/nroff.sh \
               >$@ \
        && chmod +x $@
diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh
index cf1390478..f7568ac31 100644
--- a/src/roff/nroff/nroff.sh
+++ b/src/roff/nroff/nroff.sh
@@ -1,8 +1,8 @@
-#!/bin/sh
+#!@POSIX_SHELL_PROG@
 #
 # Emulate nroff with groff.
 #
-# Copyright (C) 1992-2024 Free Software Foundation, Inc.
+# Copyright (C) 1992-2025 Free Software Foundation, Inc.
 #
 # Written by James Clark, Werner Lemberg, and G. Branden Robinson.
 #

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to