From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1A3FE1389E2 for ; Mon, 1 Dec 2014 07:34:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6C506E0899; Mon, 1 Dec 2014 07:34:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0CB08E0898 for ; Mon, 1 Dec 2014 07:34:02 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 07D7033FB4A for ; Mon, 1 Dec 2014 07:34:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AAB8FB452 for ; Mon, 1 Dec 2014 07:34:00 +0000 (UTC) From: "Tim Harder" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Tim Harder" Message-ID: <1417419219.2b6c19533a92911f4b006ff55326b24ff543a114.radhermit@gentoo> Subject: [gentoo-commits] proj/zsh-completion:master commit in: src/ X-VCS-Repository: proj/zsh-completion X-VCS-Files: src/_portage_utils X-VCS-Directories: src/ X-VCS-Committer: radhermit X-VCS-Committer-Name: Tim Harder X-VCS-Revision: 2b6c19533a92911f4b006ff55326b24ff543a114 X-VCS-Branch: master Date: Mon, 1 Dec 2014 07:34:00 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 4e422811-b53a-4763-b3b0-b713217662a8 X-Archives-Hash: f947d9458b60f701acee21538e756b32 commit: 2b6c19533a92911f4b006ff55326b24ff543a114 Author: Tim Harder gentoo org> AuthorDate: Mon Dec 1 00:47:07 2014 +0000 Commit: Tim Harder gentoo org> CommitDate: Mon Dec 1 07:33:39 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/zsh-completion.git;a=commit;h=2b6c1953 _portage_utils: sync portdir/reposconf changes from _gentoo_packages This should probably be maintained only in one place so this isn't necessary in the future. --- src/_portage_utils | 61 ++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/src/_portage_utils b/src/_portage_utils index dbb45d6..4638258 100644 --- a/src/_portage_utils +++ b/src/_portage_utils @@ -7,7 +7,7 @@ _portdir() { local mainreponame mainrepopath overlayname overlaypath if [[ -e /usr/share/portage/config/repos.conf ]]; then - if [[ ${1} == -o ]]; then + if [[ ${1} == "-o" ]]; then for overlayname in $(_parsereposconf -l); do overlaypath+=($(_parsereposconf ${overlayname} location)) done @@ -15,12 +15,9 @@ _portdir() { source /etc/make.conf 2>/dev/null source /etc/portage/make.conf 2>/dev/null - overlaypath+=(${PORTDIR_OVERLAY}) + overlaypath+=(${(@)PORTDIR_OVERLAY}) - # strip out duplicates - overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u)) - - echo "${overlaypath[@]}" + echo "${(@u)overlaypath}" else mainreponame=$(_parsereposconf DEFAULT main-repo) mainrepopath=$(_parsereposconf ${mainreponame} location) @@ -32,16 +29,16 @@ _portdir() { source /etc/make.conf 2>/dev/null source /etc/portage/make.conf 2>/dev/null - echo "${PORTDIR}" - - if [[ ${1} == -o ]]; then⋅ - echo "${PORTDIR_OVERLAY}" - fi⋅⋅⋅ + if [[ ${1} == "-o" ]]; then + echo "${(@u)PORTDIR_OVERLAY}" + else + echo "${PORTDIR}" + fi fi } _parsereposconf() { - local f insection line section v value var + local v f insection section arr for f in /usr/share/portage/config/repos.conf \ /etc/portage/repos.conf \ @@ -49,34 +46,34 @@ _parsereposconf() { [[ -f ${f} ]] || continue insection=0 + declare -A arr + IFS='= ' + + while read -r name value; do + [[ -z ${name} || ${name} == '#'* ]] && continue - while read -r line; do - # skip comments and blank lines - [[ -z ${line} || ${line} == '#'* ]] && continue + if [[ (${name} == '['*']') && (-z ${value}) ]]; then + value=${name//(\]|\[)} + name="section" + fi + arr[${name}]=${value} - if [[ ${insection} == 1 && ${line} == '['*']' ]]; then - # End of the section we were interested in so stop - secname+=(${line//[(\[|\])]/}) # record name for -l + if [[ ${insection} == 1 && ${name} == "section" ]]; then break - elif [[ ${line} == '['*']' ]]; then - # Entering a new section, check if it's the one we want - section=${line//[(\[|\])]/} - [[ ${section} == "${1}" ]] && insection=1 - secname+=(${section}) # record name for -l + elif [[ ${name} == "section" ]]; then + [[ ${value} == ${1} ]] && insection=1 + secname+=(${value}) elif [[ ${insection} == 1 ]]; then - # We're in the section we want, grab the values - var=${line%%=*} - var=${var// /} - value=${line#*=} - value=${value# } - [[ ${var} == ${2} ]] && v=${value} + if [[ ${name} == ${2} ]]; then + v=${value} + fi fi continue - done < "${f}" + done < ${f} done - if [[ ${1} == -l ]]; then - echo "${secname[@]}" + if [[ ${1} == "-l" ]]; then + echo "${(@)secname}" else echo "${v}" fi