From fabda847f4690cac36728ec8372f4fe82a8ba9f1 Mon Sep 17 00:00:00 2001 From: Tim Harder Date: Sat, 20 Dec 2014 14:27:43 -0800 Subject: _gentoo_repos: drop duplicated output functionality Also, calling _gentoo_repos with no arguments returns all configured repos instead of just the main repo. To get the path for the main repo use `_gentoo_repos -m`. --- src/_gentoo_repos | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'src/_gentoo_repos') diff --git a/src/_gentoo_repos b/src/_gentoo_repos index 3419cdc..7f88a64 100644 --- a/src/_gentoo_repos +++ b/src/_gentoo_repos @@ -1,40 +1,40 @@ #autoload # Usage: -# _gentoo_repos -> returns the main repo (with PORTDIR fallback) -# _gentoo_repos -o -> returns the list of non-main repos (with PORTDIR_OVERLAY fallback) +# _gentoo_repos -> returns the list of all repos +# _gentoo_repos -m -> returns the main repo +# _gentoo_repos -o -> returns the list of non-main repos _gentoo_repos() { - local main_repo main_repo_path overlay overlay_path + local main_repo main_repo_path overlay overlay_paths if [[ -e /usr/share/portage/config/repos.conf ]]; then - if [[ ${1} == "-o" ]]; then - for overlay in $(_repos_conf -l); do - overlay_path+=($(_repos_conf ${overlay} location)) - done + main_repo=$(_repos_conf DEFAULT main-repo) + main_repo_path=$(_repos_conf ${main_repo} location) - source /etc/make.conf 2>/dev/null - source /etc/portage/make.conf 2>/dev/null + for overlay in $(_repos_conf -l); do + overlay_paths+=($(_repos_conf ${overlay} location)) + done - overlay_path+=(${(@)PORTDIR_OVERLAY}) - - echo "${(@u)overlay_path}" - else - main_repo=$(_repos_conf DEFAULT main-repo) - main_repo_path=$(_repos_conf ${main_repo} location) + source /etc/make.conf 2>/dev/null + source /etc/portage/make.conf 2>/dev/null - echo "${main_repo_path}" - fi + overlay_paths+=(${(@)PORTDIR_OVERLAY}) else source /usr/share/portage/config/make.globals 2>/dev/null source /etc/make.conf 2>/dev/null source /etc/portage/make.conf 2>/dev/null - if [[ ${1} == "-o" ]]; then - echo "${(@u)PORTDIR_OVERLAY}" - else - echo "${PORTDIR}" - fi + main_repo_path="${PORTDIR}" + overlay_paths=(${(@)PORTDIR_OVERLAY}) + fi + + if [[ $1 == "-m" ]]; then + echo "${main_repo_path}" + elif [[ $1 == "-o" ]]; then + echo "${(@u)overlay_paths}" + else + echo "${main_repo_path} ${(@u)overlay_paths}" fi } -- cgit v1.2.3-65-gdbad