Module Name:    src
Committed By:   kim
Date:           Fri Sep 11 12:50:14 UTC 2020

Modified Files:
        src/etc/rc.d: motd

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/etc/rc.d/motd

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/etc/rc.d/motd
diff -u src/etc/rc.d/motd:1.10 src/etc/rc.d/motd:1.11
--- src/etc/rc.d/motd:1.10	Fri Sep 11 09:59:35 2020
+++ src/etc/rc.d/motd	Fri Sep 11 12:50:14 2020
@@ -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 @@ motd_start()
 	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

Reply via email to