Follow-up Comment #3, bug #68115 (group groff):

Hmm.  This is the commit that broke it, and it's not immediately obvious to me
why, though the `@g@` replacement by "shdeps.sed"
([https://lists.gnu.org/archive/html/groff/2026-03/msg00018.html as rocketdev
pointed out on the discussion list]) and this commit's alteration of a line
containing `$@` has a gunpowder smell to it.


$ git bisect good
2b86c9332c7599db2371d19a49b173593f19799d is the first bad commit
commit 2b86c9332c7599db2371d19a49b173593f19799d
Author: G. Branden Robinson <[email protected]>
Date:   Wed Feb 4 05:30:17 2026 -0600

    Stop using `${1+"$@"}` in shell scripts.
    
    ...to kludge around old broken shells.
    
    The (forthcoming) Autoconf 2.73 manual explains.
    
    ---snip---
    You may see usages like ‘${1+"$@"}’ in older shell scripts designed
to
    work around a portability problem in ancient shells.  Unfortunately this
    runs afoul of bugs in more-recent shells, and nowadays it is better to
    use plain ‘"$@"’ instead.
    
    The portability problem with ancient shells was significant.  When there
    are no positional arguments ‘"$@"’ should be discarded, but the
original
    Unix version 7 Bourne shell mistakenly treated it as equivalent to
‘""’
    instead, and many ancient shells followed its lead.
    
    For many years shell scripts worked around this portability problem by
    using ‘${1+"$@"}’ instead of ‘"$@"’, and you may see this usage in
older
    scripts.  Unfortunately, ‘${1+"$@"}’ does not work with ‘ksh93’ M
93t+
    (2009) as shipped in AIX 7.2 (2015), as this shell drops a trailing
    empty argument:
    
      $ set a b c ""
      $ set ${1+"$@"}
      $ echo $#
      3
    
    Also, ‘${1+"$@"}’ does not work with Zsh 4.2.6 (2005) and earlier, as
    shipped in Mac OS X releases before 10.5, as this old Zsh incorrectly
    word splits the result:
    
      zsh $ emulate sh
      zsh $ for i in "$@"; do echo $i; done
      Hello World
      !
      zsh $ for i in ${1+"$@"}; do echo $i; done
      Hello
      World
      !
    ---end snip---
    
    In light of all this winning by elite shell developers, use plain,
    idiomatic `"$@"` instead, relying on downstream distributors to patch
    the handful of occurrences in groff should their deployments be boxed in
    by a buggy /bin/sh.
    
    * src/preproc/eqn/neqn.sh:
    * src/roff/nroff/nroff.sh:
    * test-groff.in: Do it.

 ChangeLog               | 52
+++++++++++++++++++++++++++++++++++++++++++++++++
 src/preproc/eqn/neqn.sh |  5 +----
 src/roff/nroff/nroff.sh |  9 ++-------
 test-groff.in           |  2 +-
 4 files changed, 56 insertions(+), 12 deletions(-)




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68115>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to