Subject: add backward compatibility to wscons rc.d script
To: None <current-users@netbsd.org>
From: Jukka Salmi <j+nbsd@2007.salmi.ch>
List: current-users
Date: 04/25/2007 11:17:06
--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

revision 1.12 of src/etc/rc.d/wscons broke backward compatibility with
existing wscons.conf(5) syntax. 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 ;-)

Comments are welcome.


Regards, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~

--YZ5djTAD1cGYuMQK
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=diff

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
 				;;
 

--YZ5djTAD1cGYuMQK--