summaryrefslogtreecommitdiffstats
path: root/bin/filter-bash-environment.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-06 00:23:32 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-06 00:23:32 +0000
commit3914c583172c82ca50668acce58edf278fbef56d (patch)
tree5ef49b42a08bfd209ba216e242cb60f8fe5f7d90 /bin/filter-bash-environment.py
parent34e26c831c63788440cb80bb9d48319d630e8ba2 (diff)
downloadportage-3914c583172c82ca50668acce58edf278fbef56d.tar.gz
portage-3914c583172c82ca50668acce58edf278fbef56d.tar.bz2
portage-3914c583172c82ca50668acce58edf278fbef56d.zip
Move the variable name validation regexes (for bug 211949) into
filter-bash-environment.py instead of passing them in from bash. svn path=/main/trunk/; revision=9445
Diffstat (limited to 'bin/filter-bash-environment.py')
-rwxr-xr-xbin/filter-bash-environment.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
index 8f4b6d0cb..ab348d992 100755
--- a/bin/filter-bash-environment.py
+++ b/bin/filter-bash-environment.py
@@ -69,7 +69,7 @@ def filter_bash_environment(pattern, file_in, file_out):
here_doc_delim = re.compile("^%s$" % here_doc.group(1))
file_out.write(line)
continue
- # Note: here-documents are handled before fuctions since otherwise
+ # Note: here-documents are handled before functions since otherwise
# it would be possible for the content of a here-document to be
# mistaken as the end of a function.
if in_func:
@@ -103,7 +103,13 @@ if __name__ == "__main__":
parser.error("Missing required PATTERN argument.")
file_in = sys.stdin
file_out = sys.stdout
- var_pattern = "^(%s)$" % "|".join(args[0].split())
+ var_pattern = args[0].split()
+
+ # Filter invalid variable names that are not supported by bash.
+ var_pattern.append(r'\d.*')
+ var_pattern.append(r'.*\W.*')
+
+ var_pattern = "^(%s)$" % "|".join(var_pattern)
filter_bash_environment(
compile_egrep_pattern(var_pattern), file_in, file_out)
file_out.flush()