Fix varexpand() so that it doesn't do redundant quote removal that
authorZac Medico <zmedico@gentoo.org>
Sat, 25 Sep 2010 21:56:05 +0000 (14:56 -0700)
committerZac Medico <zmedico@gentoo.org>
Sat, 25 Sep 2010 21:56:05 +0000 (14:56 -0700)
is already handled by shlex.

This fixes a bug in getconfig() which caused it to remove backslash
characters it front of quote characters in cases where bash would
have preserved them when sourcing the same input.

pym/portage/util/__init__.py

index 9542826b20e9a9fb17ffaa249ff18782751d1779..8ba6b6c81c52d9cc85639c8fc868afd9505d9a64 100644 (file)
@@ -656,8 +656,14 @@ def varexpand(mystring, mydict=None):
                                                newstring=newstring+chr(0o11)
                                        elif a=='v':
                                                newstring=newstring+chr(0o13)
+                                       elif a in ('\'', '"'):
+                                               # Quote removal is handled by shlex.
+                                               newstring = newstring + mystring[pos-2:pos]
+                                               continue
                                        elif a!='\n':
-                                               #remove backslash only, as bash does: this takes care of \\ and \' and \" as well
+                                               # Remove backslash only, as bash does. This takes care
+                                               # of \\. Note that we don't handle quotes here since
+                                               # quote remoal is handled by shlex.
                                                newstring=newstring+mystring[pos-1:pos]
                                                continue
                        elif (mystring[pos]=="$") and (mystring[pos-1]!="\\"):