aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2015-12-09 09:34:26 +0100
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>2015-12-09 09:34:26 +0100
commite7d95cbf1e0f8a209ac1417ae2ae89ef331becfc (patch)
tree6d4516570d902c7eb29cd93a8e2c3145f8b357b5 /bin/isolated-functions.sh
parentSetConfig._create_default_config: add profile set definition (diff)
downloadportage-e7d95cbf1e0f8a209ac1417ae2ae89ef331becfc.tar.gz
portage-e7d95cbf1e0f8a209ac1417ae2ae89ef331becfc.tar.bz2
portage-e7d95cbf1e0f8a209ac1417ae2ae89ef331becfc.zip
portage.repository.config.RepoConfig: Support location with trailing whitespace by using quoting.
configparser.ConfigParser strips initial and trailing whitespace.
Diffstat (limited to 'bin/isolated-functions.sh')
-rw-r--r--bin/isolated-functions.sh20
1 files changed, 13 insertions, 7 deletions
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index 57669218d..a55d4a333 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1
@@ -473,17 +473,23 @@ has() {
}
__repo_attr() {
- local appropriate_section=0 exit_status=1 line saved_extglob_shopt=$(shopt -p extglob)
+ local appropriate_section=0 attribute=$2 exit_status=1 line repo_name=$1 saved_extglob_shopt=$(shopt -p extglob) value
shopt -s extglob
while read line; do
- [[ ${appropriate_section} == 0 && ${line} == "[$1]" ]] && appropriate_section=1 && continue
+ [[ ${appropriate_section} == 0 && ${line} == "[${repo_name}]" ]] && appropriate_section=1 && continue
[[ ${appropriate_section} == 1 && ${line} == "["*"]" ]] && appropriate_section=0 && continue
- # If a conditional expression like [[ ${line} == $2*( )=* ]] is used
- # then bash-3.2 produces an error like the following when the file is
+ # If a conditional expression like [[ ${line} == ${attribute}*( )=* ]] is used
+ # then bash <4.1 produces an error like the following when the file is
# sourced: syntax error in conditional expression: unexpected token `('
# Therefore, use a regular expression for compatibility.
- if [[ ${appropriate_section} == 1 && ${line} =~ ^${2}[[:space:]]*= ]]; then
- echo "${line##$2*( )=*( )}"
+ if [[ ${appropriate_section} == 1 && ${line} =~ ^${attribute}[[:space:]]*= ]]; then
+ value="${line##${attribute}*( )=*( )}"
+ if [[ ${attribute} =~ ^(location)$ && (${value} == "'"*"'" || ${value} == '"'*'"') ]]; then
+ # bash >=4.2:
+ # value=${value:1:-1}
+ value=${value:1:$((${#value} - 2))}
+ fi
+ echo "${value}"
exit_status=0
break
fi