Skip to content

* rebranch #refs 3 with code more clean to apply. #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
15 changes: 13 additions & 2 deletions actions/use
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
# and Dickson S. Guedes has no obligations to provide maintenance, support,
# updates, enhancements, or modifications.

source $pgvm_home/include/sites

usage()
{
echo """
Expand All @@ -41,8 +43,17 @@ TIP: you can use 'pgvm list' to see the PostgreSQL
use()
{
version=$1
[[ "x$version" == "x" ]] && usage && exit

if [[ $(echo ${#version}) -eq 3 ]]
then
list_last
elif [[ $(echo ${#version}) -eq 1 \
&& $(pgvm list|sed s/.\=\>//|cut -d "." -f 1|egrep ${version}) ]]
then
list_last
fi

[[ "x$version" == "x" ]] && usage && exit 1

version_is_installed $version && create_symlinks || {
echo "version $version is not installed"
exit 1
Expand Down
5 changes: 5 additions & 0 deletions include/helpers
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,8 @@ load_conf()
fi
done
}

list_last()
{
version=$(pgvm list|sed s/.\=\>//|egrep ${version}|sort | tail -n1)
}
4 changes: 3 additions & 1 deletion test/pgvm_comment_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ pgvm list

pgvm use 999
#status=1
#match=/^version 999 is not installed$/

pgvm use 4
#status=1
#match=/^version 4 is not installed$/

## testing version 9.2.2

Expand Down