diff options
-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 ### |