[Bug 220587] /bin/sh Incorrect options handling

[email protected] Tue, 11 Mar 2025 18:21:45 +0000
Newsgroups gmane.os.freebsd.devel.standards
Message-ID <[email protected]/bugzilla/>
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220587

--- Comment #20 from Steffen Nurpmeso <[email protected]> ---
(as an outsider comment,)

For the MUA i maintain INSTALL now says

  - All systems:
    * "$SHELL -c -- 'echo du'" is required to print "du".
      POSIX issue #1440, FreeBSD /bin/sh fails (#264319, #220587).
      The test suite works around, but consider VAL_SHELL=/better/one.

and the test of my MUA now has to redirect the entire machinery ($MAILX is
ourselves) via (works fine in practice).

The port (mail/s-nail) does not set VAL_SHELL when building.  Well, it does not
seem to hurt too many people, or they set the $SHELL variable as such...

Here the test workaround:

# "sh -c -- 'echo yes'" must echo "yes"; FreeBSD #264319, #220587: work around
if [ $("${VAL_SHELL}" -c -- 'echo yes' 2>/dev/null) = yes ]; then
        T_MAILX= T_SH=
else
        echo '! '"${VAL_SHELL}"' cannot deal with "-c -- ARG", using
workaround'
        T_MAILX=./t.mailx.sh T_SH=./t.sh.sh
        ${rm} -f ${T_MAILX} ${T_SH}
        ${cat} > ${T_MAILX} <<_EOT
#!${VAL_SHELL}
SHELL=${TMPDIR}/${T_SH}
export SHELL
exec ${MAILX} "\$@"
_EOT
        ${cat} > ${T_SH} <<_EOT
#!${VAL_SHELL}
shift 2
exec ${VAL_SHELL} -c "\${@}"
_EOT
        ${chmod} 0755 ${T_MAILX} ${T_SH}
        MAILX=${TMPDIR}/${T_MAILX}
fi

-- 
You are receiving this mail because:
You are on the CC list for the bug.