[Bug 263969] Trailing whitespace change to uname -v output not carried to motd

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 14 May 2022 11:30:43 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=263969

            Bug ID: 263969
           Summary: Trailing whitespace change to uname -v output not
                    carried to motd
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: jarrod@downtools.com.au

Created attachment 233907
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=233907&action=edit
libexec/rc/rc.d/motd patch

Commit ed87197672b44f7f76b38e6450df2b4071c88a67 to usr.bin/uname/uname.c
removed a trailing space from the end of "uname -v" output however this was not
carried through to the regular expression used in libexec/rc/rc.d/motd.

Prior to the removal, the installed /etc/rc.d/motd script would update
/etc/motd (now /var/run/motd) with output similar to below.

amnesiac> uname -v | tr " " "-"
FreeBSD-13.0-RELEASE-p7-#8:-Thu-Feb--3-17:40:35-ACDT-2022-----root@amnesiac:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-
amnesiac> grep "uname -v" /etc/rc.d/motd | sed "s# >.*##" | sh         <--
example to run the included rc.d/motd regex
FreeBSD 13.0-RELEASE-p7 (GENERIC) #8: Thu Feb  3 17:40:35 ACDT 2022    <-- note
the GENERIC kernel name and removed path
amnesiac>

Having now updated the host to FreeBSD 13.1-RELEASE, the output is no longer
modified.

amnesiac> uname -v | tr " " "-"
FreeBSD-13.1-RELEASE-#15:-Sat-May-14-17:38:59-ACST-2022-----root@amnesiac:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
amnesiac> grep "uname -v" /etc/rc.d/motd | sed "s# >.*##" | sh
FreeBSD 13.1-RELEASE #15: Sat May 14 17:38:59 ACST 2022    
root@amnesiac:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
amnesiac>

The attached patch makes the trailing space optional to the regular expression
though it may be more appropriate to drop the requirement for the trailing
space altogether. This restores the previous behaviour.

amnesiac> uname -v | tr " " "-"
FreeBSD-13.1-RELEASE-#15:-Sat-May-14-17:38:59-ACST-2022-----root@amnesiac:/usr/obj/usr/src/amd64.amd64/sys/GENERIC
amnesiac> grep "uname -v" /etc/rc.d/motd | sed "s# >.*##" | sh
FreeBSD 13.1-RELEASE (GENERIC) #15: Sat May 14 17:38:59 ACST 2022
amnesiac>

-- 
You are receiving this mail because:
You are the assignee for the bug.