Index: trunk/base/src/darwinports1.0/darwinports.tcl
===================================================================
--- trunk/base/src/darwinports1.0/darwinports.tcl	(revision 18673)
+++ trunk/base/src/darwinports1.0/darwinports.tcl	(revision 18681)
@@ -1,4 +1,4 @@
 # darwinports.tcl
-# $Id: darwinports.tcl,v 1.212 2006/04/05 23:51:50 jberry Exp $
+# $Id: darwinports.tcl,v 1.213 2006/07/22 05:50:40 pguyot Exp $
 #
 # Copyright (c) 2002 Apple Computer, Inc.
@@ -225,5 +225,5 @@
 	    while {[gets $fd line] >= 0} {
 		foreach option $bootstrap_options {
-		    if {[regexp "^$option\[ \t\]+(\[A-Za-z0-9_:,\./-\]+$)" $line match val] == 1} {
+		    if {[regexp "^$option\[ \t\]+(\[A-Za-z0-9_:,\./-\].+$)" $line match val] == 1} {
 			set darwinports::$option $val
 			global darwinports::$option
@@ -435,7 +435,7 @@
 					}
     if {[info exists extra_env]} {
-    	lappend keepenvkeys ${extra_env}
-    }
-
+    	set keepenvkeys [concat ${keepenvkeys} ${extra_env}]
+    }
+	
 	foreach envkey [array names env] {
 		if {[lsearch $keepenvkeys $envkey] == -1} {
Index: trunk/base/tests/Makefile
===================================================================
--- trunk/base/tests/Makefile	(revision 18673)
+++ trunk/base/tests/Makefile	(revision 18681)
@@ -1,6 +1,5 @@
 include ../Mk/dports.autoconf.mk
 
-#SUBDIR=checksums-1 site-tags trace xcodeversion
-SUBDIR=checksums-1 site-tags xcodeversion
+SUBDIR=checksums-1 envvariables site-tags trace xcodeversion
 
 .PHONY: test
@@ -43,4 +42,5 @@
 		fi || exit 1; \
 	done
+	@rm -rf /tmp/darwinports-tests/
 
 install:
Index: trunk/base/tests/envvariables/Makefile
===================================================================
--- trunk/base/tests/envvariables/Makefile	(revision 18681)
+++ trunk/base/tests/envvariables/Makefile	(revision 18681)
@@ -0,0 +1,18 @@
+include ../../Mk/dports.autoconf.mk
+
+.PHONY: test
+
+$(bindir)/port:
+	@echo "Please install DarwinPorts before running this test"
+	@exit 1
+	
+test:
+	@PORTSRC=$(PORTSRC) $(bindir)/port clean > /dev/null
+	@sh -c "export ENVA=A ; export ENVB=B; \
+		export PORTSRC=$(PORTSRC); $(bindir)/port -t test" > output 2>&1 || (cat output; exit 1)
+	@diff output master 2>&1 | tee difference
+	@if [ -s difference ]; then \
+		exit 1; \
+	else \
+		rm -f difference; \
+	fi
Index: trunk/base/tests/envvariables/Portfile
===================================================================
--- trunk/base/tests/envvariables/Portfile	(revision 18681)
+++ trunk/base/tests/envvariables/Portfile	(revision 18681)
@@ -0,0 +1,24 @@
+# $Id: Portfile,v 1.1 2006/07/22 05:50:41 pguyot Exp $
+
+PortSystem 1.0
+name		envvariables
+version		1
+categories	test
+maintainers	pguyot@kallisys.net
+description	Test port for env variables
+homepage	http://darwinports.opendarwin.org/
+platforms	darwin
+
+long_description ${description}
+
+fetch		{}
+checksum	{}
+extract		{}
+configure	{}
+build		{}
+destroot	{}
+
+test {
+	puts $env(ENVA)
+	puts $env(ENVB)
+}
Index: trunk/base/tests/envvariables/master
===================================================================
--- trunk/base/tests/envvariables/master	(revision 18681)
+++ trunk/base/tests/envvariables/master	(revision 18681)
@@ -0,0 +1,8 @@
+--->  Fetching envvariables
+--->  Verifying checksum(s) for envvariables
+--->  Extracting envvariables
+--->  Configuring envvariables
+--->  Building envvariables with target all
+--->  Testing envvariables
+A
+B
Index: trunk/base/tests/test-ports.conf
===================================================================
--- trunk/base/tests/test-ports.conf	(revision 18673)
+++ trunk/base/tests/test-ports.conf	(revision 18681)
@@ -49,2 +49,8 @@
 # Rsync options
 rsync_options		"-rtzv --delete --delete-after"
+
+# Extra environment variables to keep. Any variables listed here are added
+# to the list of variables that are not removed from the environment used
+# while processing ports
+# extra_env                     KEEP_THIS THIS_TOO
+extra_env			ENVA ENVB
