For bug #177591, increase shell compatibility by preserving quotes in varexpand(...
authorZac Medico <zmedico@gentoo.org>
Tue, 8 May 2007 20:29:02 +0000 (20:29 -0000)
committerZac Medico <zmedico@gentoo.org>
Tue, 8 May 2007 20:29:02 +0000 (20:29 -0000)
svn path=/main/trunk/; revision=6505

pym/portage/util.py

index aad939529fb34322f1b0648530ac85472f5f1dd4..46fc6e462a764a4021c33da3d388f2124cb2d776 100644 (file)
@@ -351,13 +351,13 @@ def getconfig(mycfg, tolerant=0, allow_sourcing=False, expand=True):
        
 #cache expansions of constant strings
 cexpand={}
-def varexpand(mystring,mydict={}):
+def varexpand(mystring, mydict={}):
        newstring = cexpand.get(" "+mystring, None)
        if newstring is not None:
                return newstring
 
        """
-       new variable expansion code.  Removes quotes, handles \n, etc.
+       new variable expansion code.  Preserves quotes, handles \n, etc.
        This code is used by the configfile code, as well as others (parser)
        This would be a good bunch of code to port to C.
        """
@@ -373,6 +373,7 @@ def varexpand(mystring,mydict={}):
                        if (indoub):
                                newstring=newstring+"'"
                        else:
+                               newstring += "'" # Quote removal is handled by shlex.
                                insing=not insing
                        pos=pos+1
                        continue
@@ -380,6 +381,7 @@ def varexpand(mystring,mydict={}):
                        if (insing):
                                newstring=newstring+'"'
                        else:
+                               newstring += '"' # Quote removal is handled by shlex.
                                indoub=not indoub
                        pos=pos+1
                        continue