summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-03-05 23:48:50 +0000
committerZac Medico <zmedico@gentoo.org>2008-03-05 23:48:50 +0000
commit10b08a0b7e4f0e2ce810bd26d29b459cc7210409 (patch)
tree36a6290ec253d6601cafa7bf669eff8375de1b00
parentb2fe18e3cdcc40fbb3e5304b2bc9f9fc3de4c58e (diff)
downloadportage-10b08a0b7e4f0e2ce810bd26d29b459cc7210409.tar.gz
portage-10b08a0b7e4f0e2ce810bd26d29b459cc7210409.tar.bz2
portage-10b08a0b7e4f0e2ce810bd26d29b459cc7210409.zip
Pass a space-separated list of variables into filter-bash-environment.py and
generate the final regex on the python side instead of in bash. Also, properly anchor the regex so that it actually works. svn path=/main/trunk/; revision=9443
-rwxr-xr-xbin/ebuild.sh11
-rwxr-xr-xbin/filter-bash-environment.py3
2 files changed, 5 insertions, 9 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 3268c9b0e..061e1961c 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -1417,7 +1417,7 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME"
# builtin command. To avoid this problem, this function filters those
# variables out and discards them. See bug #190128.
filter_readonly_variables() {
- local x filtered_vars var_grep
+ local x filtered_vars
local readonly_bash_vars="DIRSTACK EUID FUNCNAME GROUPS
PIPESTATUS PPID SHELLOPTS UID"
local filtered_sandbox_vars="SANDBOX_ACTIVE SANDBOX_BASHRC
@@ -1445,17 +1445,12 @@ filter_readonly_variables() {
${PORTAGE_MUTABLE_FILTERED_VARS}
"
fi
- set -f
- for x in ${filtered_vars} ; do
- var_grep="${var_grep}|${x}"
- done
- set +f
- var_grep=${var_grep:1} # strip the first |
+
# The sed is to remove the readonly attribute from variables such as those
# listed in READONLY_EBUILD_METADATA, since having any readonly attributes
# persisting in the saved environment can be inconvenient when it
# eventually needs to be reloaded.
- "${PORTAGE_BIN_PATH}"/filter-bash-environment.py "${var_grep}" | sed -r \
+ "${PORTAGE_BIN_PATH}"/filter-bash-environment.py "${filtered_vars}" | sed -r \
-e 's:^declare[[:space:]]+-r[[:space:]]+:declare :' \
-e 's:^declare[[:space:]]+-([[:alnum:]]*)r([[:alnum:]]*)[[:space:]]+:declare -\1\2 :'
}
diff --git a/bin/filter-bash-environment.py b/bin/filter-bash-environment.py
index 0a88f710b..c5d5da45e 100755
--- a/bin/filter-bash-environment.py
+++ b/bin/filter-bash-environment.py
@@ -102,6 +102,7 @@ if __name__ == "__main__":
parser.error("Missing required PATTERN argument.")
file_in = sys.stdin
file_out = sys.stdout
+ var_pattern = "^(%s)$" % "|".join(args[0].split())
filter_bash_environment(
- compile_egrep_pattern(args[0]), file_in, file_out)
+ compile_egrep_pattern(var_pattern), file_in, file_out)
file_out.flush()