[Lunar-commits] r27017 - lunar/trunk/var/lib/lunar/functions

Stefan Wold ratler at lunar-linux.org
Mon Mar 17 18:17:53 CET 2008


Author: ratler
Date: 2008-03-17 18:17:53 +0100 (Mon, 17 Mar 2008)
New Revision: 27017

Modified:
   lunar/trunk/var/lib/lunar/functions/config.lunar
Log:
Third time is the charm. Some variables are sent into set_local_config with leading/trailing spaces.
Added a bashism to strip the spaces. Also changed the matching regex for the sedit to /^\s*$VAR=/


Modified: lunar/trunk/var/lib/lunar/functions/config.lunar
===================================================================
--- lunar/trunk/var/lib/lunar/functions/config.lunar	2008-03-17 10:58:55 UTC (rev 27016)
+++ lunar/trunk/var/lib/lunar/functions/config.lunar	2008-03-17 17:17:53 UTC (rev 27017)
@@ -23,9 +23,13 @@
 	local LINE NEW FILE VAR
 	debug_msg "set_config ($@)"
 
-	LINE=$(grep -w "$2=.*" $1)
+	# remove leading/trailing whitespace
+	VAR=${2#"${2%%[![:space:]]*}"}
+	VAR=${VAR%%+([[:space:]])}
+
+	LINE=$(grep -w "$VAR=.*" $1)
 	FILE=$1
-	VAR=$2
+
 	shift 2
 	if [ "$FILE" == "$LOCAL_CONFIG" ] ; then
 		NEW="$(printf "%16s" "$VAR")=\"$@\""
@@ -40,7 +44,7 @@
 
 	lock_file $FILE &&
 	if [ -n "$LINE" ] ; then
-		sedit "/\b$VAR=/d" $FILE
+		sedit "/^\s*$VAR=/d" $FILE
 	fi
 	echo "$NEW" >> $FILE
 	unlock_file $FILE



More information about the Lunar-commits mailing list