Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc/rc.d Make a ": " suffix a fixed part of the release info...



details:   https://anonhg.NetBSD.org/src/rev/a6ebacfc3560
branches:  trunk
changeset: 938576:a6ebacfc3560
user:      kim <kim%NetBSD.org@localhost>
date:      Fri Sep 11 12:50:14 2020 +0000

description:
Make a ": " suffix a fixed part of the release info tag

This results in correct updates to /etc/motd even when the value of
motd_release_tag is changed (a likely event).

Add safe quoting to outputting the read kernel version.

Thanks to kre@ for the feedback.

diffstat:

 etc/rc.d/motd |  10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diffs (29 lines):

diff -r 035f7a20815a -r a6ebacfc3560 etc/rc.d/motd
--- a/etc/rc.d/motd     Fri Sep 11 12:20:01 2020 +0000
+++ b/etc/rc.d/motd     Fri Sep 11 12:50:14 2020 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: motd,v 1.10 2020/09/11 09:59:35 kim Exp $
+# $NetBSD: motd,v 1.11 2020/09/11 12:50:14 kim Exp $
 #
 
 # PROVIDE: motd
@@ -26,13 +26,13 @@
        fi
        ( umask 022
        T=/etc/_motd
-       sysctl -n kern.version | while read i; do echo $i; break; done > $T
+       sysctl -n kern.version | while read i; do echo "$i"; break; done > $T
        if checkyesno update_motd_release; then
-               local t="${motd_release_tag}"
-               sed -En '1{/^NetBSD/{s/^/'"$t"'/;h;d;};q;}
+               local t=$(echo "${motd_release_tag%%:*}" | tr -d /)
+               sed -En '1{/^NetBSD/{'"${t:+s/^/${t}: /;}"'h;d;};q;}
                    /^ *Build ID */{s//(/;s/$/)/;H;g;y/\n/ /;p;q;}
                    ${g;p;}' < /etc/release >> $T
-               sed -E '1,2{/^'"${t+(${t})?}"'NetBSD/{d;};};' \
+               sed -E '1,2{/^([^:]*: )?NetBSD/{d;};};' \
                    < /etc/motd >> $T
        else
                sed '1{/^NetBSD.*/{d;};};' < /etc/motd >> $T



Home | Main Index | Thread Index | Old Index