Update of /cvsroot/jython/jython/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv8041
Modified Files:
javaos.py
Log Message:
Fix a ValueError when faced with enviroment values with \n in the value.
The patch will correctly support some form of values with \n.
Some values are still not handled correctly, say:
X='My\nPATH=Kevin'
Such a value may cause the original PATH to overriden.
Patch from Kevin Butler.
Index: javaos.py
===================================================================
RCS file: /cvsroot/jython/jython/Lib/javaos.py,v
retrieving revision 2.10
retrieving revision 2.11
diff -C2 -d -r2.10 -r2.11
*** javaos.py 2001/11/14 17:57:26 2.10
--- javaos.py 2001/11/15 08:17:17 2.11
***************
*** 267,276 ****
def _getEnvironment( self ):
"""Get the environment variables by spawning a subshell.
"""
p = self.execute( self.getEnv )
env = {}
for line in self._readLines( p.getInputStream() ):
! i = line.index( '=' )
! env[ self._keyTransform(line[:i])] = line[i+1:]
return env
--- 267,285 ----
def _getEnvironment( self ):
"""Get the environment variables by spawning a subshell.
+ This allows multi-line variables as long as subsequent lines do
+ not have '=' signs.
"""
p = self.execute( self.getEnv )
env = {}
+ key = 'firstLine' # in case first line had no '='
for line in self._readLines( p.getInputStream() ):
! try:
! i = line.index( '=' )
! key = self._keyTransform(line[:i])
! value = line[i+1:]
! except ValueError:
! # found no '=', so this line is part of previous value
! value = '%s\n%s' % ( value, line )
! env[ key ] = value
return env
|