summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-07-01 01:47:14 -0700
committerZac Medico <zmedico@gentoo.org>2011-07-01 01:47:14 -0700
commit799c576de2afb31cea67cb2b186051bcdae29b1e (patch)
treed1c7d1212a92e61d704dfa2cfe8fa94501b70fae
parenta30cc13e70baad6abf41224afadf4a91dd3eb828 (diff)
downloadportage-799c576de2afb31cea67cb2b186051bcdae29b1e.tar.gz
portage-799c576de2afb31cea67cb2b186051bcdae29b1e.tar.bz2
portage-799c576de2afb31cea67cb2b186051bcdae29b1e.zip
varexpand: remove escaped newline characters
This fixes a regression reported in bug 365033, comment #14.
-rw-r--r--pym/portage/tests/util/test_varExpand.py8
-rw-r--r--pym/portage/util/__init__.py7
2 files changed, 10 insertions, 5 deletions
diff --git a/pym/portage/tests/util/test_varExpand.py b/pym/portage/tests/util/test_varExpand.py
index 9dd488ea3..4af8f80c2 100644
--- a/pym/portage/tests/util/test_varExpand.py
+++ b/pym/portage/tests/util/test_varExpand.py
@@ -25,9 +25,10 @@ class VarExpandTestCase(TestCase):
"""
We want to behave like bash does when expanding a variable
assignment in a sourced file, in which case it performs
- backslash removal for \\ and \$ but nothing more. Note that
- we don't handle escaped quotes here, since genconfig() uses
- shlex to handle that earlier.
+ backslash removal for \\ and \$ but nothing more. It also
+ removes escaped newline characters. Note that we don't
+ handle escaped quotes here, since genconfig() uses shlex
+ to handle that earlier.
"""
varDict = {}
@@ -43,6 +44,7 @@ class VarExpandTestCase(TestCase):
("\\n", "\\n"),
("\\r", "\\r"),
("\\t", "\\t"),
+ ("\\\n", ""),
("\\\"", "\\\""),
("\\'", "\\'"),
]
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 85b2adaf9..5468e28c9 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -687,8 +687,9 @@ def varexpand(mystring, mydict=None):
# echo -e, but that's not needed for our purposes. We want to
# behave like bash does when expanding a variable assignment
# in a sourced file, in which case it performs backslash
- # removal for \\ and \$ but nothing more. Note that we don't
- # handle escaped quotes here, since getconfig() uses shlex
+ # removal for \\ and \$ but nothing more. It also removes
+ # escaped newline characters. Note that we don't handle
+ # escaped quotes here, since getconfig() uses shlex
# to handle that earlier.
if (pos+1>=len(mystring)):
newstring=newstring+mystring[pos]
@@ -698,6 +699,8 @@ def varexpand(mystring, mydict=None):
pos = pos + 2
if a in ("\\", "$"):
newstring = newstring + a
+ elif a == "\n":
+ pass
else:
newstring = newstring + mystring[pos-2:pos]
continue