diff options
author | 2013-07-13 14:03:56 +0000 | |
---|---|---|
committer | 2013-07-13 14:03:56 +0000 | |
commit | 17ade1e1b3803299c3de9315e40a2b6518fc2642 (patch) | |
tree | eee2622103c66c4de8955139c687752164ed98f4 | |
parent | Correct variable typo (diff) | |
download | eselect-17ade1e1b3803299c3de9315e40a2b6518fc2642.tar.gz eselect-17ade1e1b3803299c3de9315e40a2b6518fc2642.tar.bz2 eselect-17ade1e1b3803299c3de9315e40a2b6518fc2642.zip |
Refine get_slots() Logic
get_slots() shouldn't return false positives now.
-rw-r--r-- | postgresql.eselect | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/postgresql.eselect b/postgresql.eselect index e49361a..52aae84 100644 --- a/postgresql.eselect +++ b/postgresql.eselect @@ -94,9 +94,20 @@ unlinker() { ### Get Slots Function ### # Find all available slots in the preferred lib_dir() and return them. get_slots() { - echo $(find "${B_PATH}/$(lib_dir)/" -maxdepth 1 -type d \ + local slot + local found_slots + + for slot in $(find "${B_PATH}/$(lib_dir)/" -maxdepth 1 -type d \ -regex '.*postgresql-[0-9][0-9]*\.[0-9][0-9]*' | \ sed -re 's#.*([0-9]+\.[0-9]+)$#\1#' | sort -n) + do + # Check that pg_config exists for this slot, otherwise we have + # a false positive. + [[ -x "${B_PATH}/$(lib_dir)/postgresql-${slot}/bin/pg_config" ]] && \ + found_slots+=( ${slot} ) + done + + echo ${found_slots[@]} } ### List Action ### |