aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2019-09-08 09:35:51 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2019-09-08 09:35:51 +0100
commit84ba7d0ccde1869bed07f9d9b9c2fac09f48c13a (patch)
treed182dee4e815540f0afcf047790ba7e5f65ff822
parentgcc-config: Ignore PATH set in profile files. (diff)
downloadgcc-config-84ba7d0c.tar.gz
gcc-config-84ba7d0c.tar.bz2
gcc-config-84ba7d0c.zip
gcc-config: consolidate profiles sourcing logic in a single functionv2.1
Bug: https://bugs.gentoo.org/174422 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
-rwxr-xr-xgcc-config29
1 files changed, 11 insertions, 18 deletions
diff --git a/gcc-config b/gcc-config
index 9965449..dd11c71 100755
--- a/gcc-config
+++ b/gcc-config
@@ -80,16 +80,15 @@ show_var() {
echo "${!1}"
}
-# Compatibility with profile files created before 2019-09-05.
-# These profile files were setting PATH variable.
-# Sourcing them without restoring previous PATH value breaks gcc-config.
-source_profile_pre() {
- __PATH__=${PATH}
-}
+source_profile() {
+ # Compatibility with profile files created before 2019-09-05.
+ # These profile files were setting PATH variable.
+ # Sourcing them without restoring previous PATH value breaks gcc-config.
+ local backup_PATH=${PATH}
+
+ source "$1"
-source_profile_post() {
- PATH=${__PATH__}
- unset __PATH__
+ PATH=${backup_PATH}
}
try_real_hard_to_find_CHOST() {
@@ -545,9 +544,7 @@ prefix_copy_gcc_libs() {
for x in ${GCC_PROFILES} ; do
unset GCC_PATH LDPATH
eval $(
- source_profile_pre
- source "${x}"
- source_profile_post
+ source_profile "${x}"
echo "GCC_PATH='${GCC_PATH}'"
echo "LDPATH='${LDPATH%%:*}'"
)
@@ -613,9 +610,7 @@ switch_profile() {
# Setup things properly again for this profile
unset GCC_SPECS LDPATH MULTIOSDIRS
- source_profile_pre
- source "${GCC_ENV_D}/${CC_COMP}"
- source_profile_post
+ source_profile "${GCC_ENV_D}/${CC_COMP}"
# Support older configs that did not setup MULTIOSDIRS for us.
: ${MULTIOSDIRS:=../${GENTOO_LIBDIR}}
@@ -830,9 +825,7 @@ list_profiles() {
if [[ ${x} == ${CURRENT_NATIVE} ]] ; then
x="${x} ${GOOD}*${NORMAL}"
elif [[ -e ${GCC_ENV_D}/config-${target} ]] ; then
- source_profile_pre
- source "${GCC_ENV_D}/config-${target}"
- source_profile_post
+ source_profile "${GCC_ENV_D}/config-${target}"
[[ ${x} == ${CURRENT} ]] && x="${x} ${HILITE}*${NORMAL}"
fi
echo " [${i}] ${x}"