aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYING24
-rw-r--r--README9
-rwxr-xr-xrbpm.sh15
3 files changed, 28 insertions, 20 deletions
diff --git a/COPYING b/COPYING
index 415fdd6..633f1a7 100644
--- a/COPYING
+++ b/COPYING
@@ -1,21 +1,19 @@
-The MIT License (MIT)
+Copyright 2014 David Vazgenovich Shakaryan
-Copyright (c) 2014 David Vazgenovich Shakaryan
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README b/README
index f3b1253..339a889 100644
--- a/README
+++ b/README
@@ -1,18 +1,19 @@
rbpm (ruby path mangler)
-https://github.com/omp/rbpm
+https://git.potato.am/rbpm.git/
Manage multiple Ruby installations with no black magic.
NOTES
rbpm only manages rubies located in the ~/.rubies directory. This
- behaviour can be changed by setting the RUBIES_PATH environment
+ directory can be changed by setting the RUBIES_PATH environment
variable to some other location. rbpm does not display information
about rubies it does not manage, such as any system-wide install.
- rbpm performs a substring match when selecting a ruby, using the
- highest matching directory when there are multiple matches.
+ rbpm performs a substring match when selecting a ruby. If there are
+ multiple matches, it gives precedence to matches at the start of the
+ version. If there are still multiple, the greatest of those is used.
DEPENDENCIES
diff --git a/rbpm.sh b/rbpm.sh
index 290b9f1..619fc03 100755
--- a/rbpm.sh
+++ b/rbpm.sh
@@ -4,7 +4,7 @@
# Distributed under the terms of the MIT License.
#
# rbpm (ruby path mangler)
-# https://github.com/omp/rbpm
+# https://git.potato.am/rbpm.git/
# Manage multiple Ruby installations with no black magic.
#
# In order to prevent environment pollution, the output of this script
@@ -16,7 +16,7 @@
# Placing the above function inside ~/.bashrc (or equivalent) will load
# it upon starting your shell.
-RBPM_VERSION='0.1'
+RBPM_VERSION='0.2'
: ${RUBIES_PATH:="${HOME}/.rubies"}
@@ -121,17 +121,26 @@ rbpm_get() {
rbpm_set() {
[[ -n "${1}" ]] || _die 'set command requires an argument.'
- local dir dirs match
+ local dir dirs match match_start
_populate_dirs
for dir in "${dirs[@]}"; do
if [[ "${dir##*/}" == *"${1}"* ]]; then
match="${dir}"
+
+ # Match from start of version is preferred. We assume the version
+ # is at the beginning of the directory name or following a hyphen.
+ # This avoids surprising behaviour like `2.1' matching `2.2.1' over
+ # `2.1.0'.
+ if [[ "${dir##*/}" == "${1}"* || "${dir##*/}" == *-"${1}"* ]]; then
+ match_start="${dir}"
+ fi
fi
done
[[ -n "${match}" ]] || _die 'no matching ruby found.'
+ [[ -n "${match_start}" ]] && match="${match_start}"
_clear
_add "${match}"