Subject: misc/36232: add backward compatibility to wscons rc.d script (patch supplied)
To: None <misc-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <j+nbsd@2007.salmi.ch>
List: netbsd-bugs
Date: 04/28/2007 13:00:00
>Number:         36232
>Category:       misc
>Synopsis:       add backward compatibility to wscons rc.d script (patch supplied)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Apr 28 13:00:00 +0000 2007
>Originator:     Jukka Salmi
>Release:        NetBSD 4.99.18
>Environment:
System: NetBSD moray.salmi.ch 4.99.18 NetBSD 4.99.18 (MORAY.APM) #0: Thu Apr 26 01:13:24 CEST 2007 build@moray.salmi.ch:/b/build/nbsd/c/i386/sys/arch/i386/compile/MORAY.APM i386
Architecture: i386
Machine: i386
>Description:
Revision 1.12 of src/etc/rc.d/wscons broke backward compatibility with
existing wscons.conf(5) syntax and didn't even document this change.
>How-To-Repeat:
Add a `setvar ...' line in wscons.conf(5) syntax to /etc/wscons.conf
and run `/etc/rc.d/wscons start'...
>Fix:
The attached patch teaches the wscons script to understand both new
and old config file syntax. Additionally, it allows for the old
"variable=value" and the new "variable" "value" syntax to be used for
both syntaxes; this is also backward compatible and thus can be seen
as a feature ;-)

If only the new syntax should be supported, then it used should be
documented in wscons.conf(5).

The patch is also available from
http://salmi.ch/~jukka/patches/nbsd/HEAD/etc/rc.d/wscons.patch

Index: etc/rc.d/wscons
===================================================================
RCS file: /cvsroot/src/etc/rc.d/wscons,v
retrieving revision 1.12
diff -u -p -r1.12 wscons
--- etc/rc.d/wscons	2 Apr 2007 12:42:42 -0000	1.12
+++ etc/rc.d/wscons	25 Apr 2007 09:14:06 -0000
@@ -157,23 +157,42 @@ wscons_start()
 				;;
 
 			setvar)
-				dev=$arg1
-				var=$arg2
-				val=$arg3
-
-				case $dev in
-				    ttyE*)
-					cmdmod="-d"
-					;;
-				    wskbd*)
-					cmdmod="-k"
-					;;
-				    wsmouse*)
-					cmdmod="-m"
-					;;
+				set -- "$arg1" "$arg2" "$arg3"
+				case "$1" in
+					wskbd*)
+						echo -n "$1: "
+						cmd="$wsctl -f /dev/$1 -k"
+						shift
+						;;
+					ttyE*)
+						echo -n "$1: "
+						cmd="$wsctl -f /dev/$1 -d"
+						shift
+						;;
+					wsmouse*)
+						echo -n "$1: "
+						cmd="$wsctl -f /dev/$1 -m"
+						shift
+						;;
+					# be backward compatible with
+					# old wscons.conf(5) syntax:
+					keyboard)
+						cmd="$wsctl -k"
+						shift
+						;;
+					display)
+						cmd="$wsctl -d"
+						shift
+						;;
+					mouse)
+						cmd="$wsctl -m"
+						shift
+						;;
+					*)
+						cmd="$wsctl"
+						;;
 				esac
-				echo -n "$dev: "
-				cmd="$wsctl -f /dev/$dev $cmdmod -w $var=$val"
+				cmd="$cmd -w ${1}${2+=${2}}"
 				eval $DOIT $cmd
 				;;