summaryrefslogtreecommitdiffstats
path: root/bin/filter-bash-environment.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-09-01 19:32:26 +0000
committerZac Medico <zmedico@gentoo.org>2008-09-01 19:32:26 +0000
commitb5777ba47fa650a1f8be6f0c10f6dbcb9999e1a7 (patch)
tree54503a6833bf0a230b086b52b959451e8ef78d91 /bin/filter-bash-environment.py
parent9b976780c4017332572f1fd2d1ee735aae4b4950 (diff)
downloadportage-b5777ba47fa650a1f8be6f0c10f6dbcb9999e1a7.tar.gz
portage-b5777ba47fa650a1f8be6f0c10f6dbcb9999e1a7.tar.bz2
portage-b5777ba47fa650a1f8be6f0c10f6dbcb9999e1a7.zip
Bug #222091 - Filter out any instances of the \1 character from variable
values since this character multiplies each time that the environment is saved (strange bash behavior). This can eventually result in mysterious 'Argument list too long' errors from programs that have huge strings of \1 characters in their environment. svn path=/main/trunk/; revision=11485
Diffstat (limited to 'bin/filter-bash-environment.py')
-rwxr-xr-xbin/filter-bash-environment.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
index d3434ff0e..42ebd7447 100755
--- a/bin/filter-bash-environment.py
+++ b/bin/filter-bash-environment.py
@@ -25,6 +25,11 @@ def have_end_quote(quote, line):
close_quote_match.group(1) == quote
def filter_bash_environment(pattern, file_in, file_out):
+ # Filter out any instances of the \1 character from variable values
+ # since this character multiplies each time that the environment
+ # is saved (strange bash behavior). This can eventually result in
+ # mysterious 'Argument list too long' errors from programs that have
+ # huge strings of \1 characters in their environment. See bug #222091.
here_doc_delim = None
in_func = None
multi_line_quote = None
@@ -32,7 +37,7 @@ def filter_bash_environment(pattern, file_in, file_out):
for line in file_in:
if multi_line_quote is not None:
if not multi_line_quote_filter:
- file_out.write(line)
+ file_out.write(line.replace("\1", ""))
if have_end_quote(multi_line_quote, line):
multi_line_quote = None
multi_line_quote_filter = None
@@ -59,7 +64,7 @@ def filter_bash_environment(pattern, file_in, file_out):
(declare_opts, line[readonly_match.end():])
else:
line = "declare " + line[readonly_match.end():]
- file_out.write(line)
+ file_out.write(line.replace("\1", ""))
continue
if here_doc_delim is not None:
if here_doc_delim.match(line):