diff options
author | 2013-08-12 10:47:00 -0600 | |
---|---|---|
committer | 2013-08-12 10:47:00 -0600 | |
commit | 496329ce9e22cd4d0a91e3039224e58e3be4857b (patch) | |
tree | 3b1e8f5a2ee562ee425651fe73c2a7077cce030c | |
parent | Credit Alexander. (diff) | |
download | gentoo-bashcomp-496329ce9e22cd4d0a91e3039224e58e3be4857b.tar.gz gentoo-bashcomp-496329ce9e22cd4d0a91e3039224e58e3be4857b.tar.bz2 gentoo-bashcomp-496329ce9e22cd4d0a91e3039224e58e3be4857b.zip |
Fix whitespace.
-rw-r--r-- | gentoo | 144 |
1 files changed, 72 insertions, 72 deletions
@@ -23,83 +23,83 @@ # This would be a hell of a lot simpler if we used portageq, but also about # 500 times slower. _portdir() { - if [[ -e @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf ]]; then - if [[ ${1} == '-o' ]]; then - for overlayname in $(_parsereposconf -l); do - overlaypath+=($(_parsereposconf ${overlayname} location)) - done - - source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null - source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null - - overlaypath+=(${PORTDIR_OVERLAY}) - - # strip out duplicates - overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u)) - - echo "${overlaypath[@]}" - else - mainreponame=$(_parsereposconf DEFAULT main-repo) - mainrepopath=$(_parsereposconf ${mainreponame} location) - - echo "${mainrepopath}" - fi - else - source @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/make.globals 2>/dev/null - source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null - source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null - - echo "${PORTDIR}" - - if [[ ${1} == '-o' ]]; then - echo "${PORTDIR_OVERLAY}" - fi - fi + if [[ -e @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf ]]; then + if [[ ${1} == '-o' ]]; then + for overlayname in $(_parsereposconf -l); do + overlaypath+=($(_parsereposconf ${overlayname} location)) + done + + source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null + source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null + + overlaypath+=(${PORTDIR_OVERLAY}) + + # strip out duplicates + overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u)) + + echo "${overlaypath[@]}" + else + mainreponame=$(_parsereposconf DEFAULT main-repo) + mainrepopath=$(_parsereposconf ${mainreponame} location) + + echo "${mainrepopath}" + fi + else + source @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/make.globals 2>/dev/null + source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null + source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null + + echo "${PORTDIR}" + + if [[ ${1} == '-o' ]]; then + echo "${PORTDIR_OVERLAY}" + fi + fi } # _parsereposconf [-l] <repo> <variable> # -l lists available repos _parsereposconf() { - local f insection line section v value var - - for f in @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf \ - @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf \ - @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf/*.conf; do - - if [[ -f ${f} ]]; then - insection=0 - - while read line; do - # skip comments and blank lines - [[ -z ${line} || ${line:0:1} == "#" ]] && continue - - if [[ ${insection} == 1 && ${line} =~ ^\[.*\]$ ]]; then - # End of the section we were interested in so stop - secname+=(${line//[(\[|\])]/}) # record name for -l - 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 [[ ${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}" - fi - continue - done < "${f}" - fi - done - - if [[ ${1} == -l ]]; then - echo "${secname[@]}" - else - echo "${v}" - fi + local f insection line section v value var + + for f in @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf \ + @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf \ + @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf/*.conf; do + + if [[ -f ${f} ]]; then + insection=0 + + while read line; do + # skip comments and blank lines + [[ -z ${line} || ${line:0:1} == "#" ]] && continue + + if [[ ${insection} == 1 && ${line} =~ ^\[.*\]$ ]]; then + # End of the section we were interested in so stop + secname+=(${line//[(\[|\])]/}) # record name for -l + 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 [[ ${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}" + fi + continue + done < "${f}" + fi + done + + if [[ ${1} == -l ]]; then + echo "${secname[@]}" + else + echo "${v}" + fi } # like _pkgname but completes on package names only (no category) |