diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-06-15 00:45:04 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-06-15 00:45:04 -0700 |
commit | 60a0e7180937ef85c6a04a6c82e57c2ffab52d7a (patch) | |
tree | 2eee5241b9694846efb464cf9bd22ef463532740 /rpath.sh | |
parent | 6bfa3b3efb8fbc3c447fd5ca93b9f0c1f10563ad (diff) | |
download | rbpm-60a0e7180937ef85c6a04a6c82e57c2ffab52d7a.tar.gz rbpm-60a0e7180937ef85c6a04a6c82e57c2ffab52d7a.tar.xz |
Output warning when multiple rubies are in PATH.
Diffstat (limited to 'rpath.sh')
-rwxr-xr-x | rpath.sh | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -29,8 +29,12 @@ _export_path() { echo "hash -r" } +_warn() { + echo "echo '${@//\'/\'\\\'\'}' 1>&2" +} + _die() { - [[ -n "${@}" ]] && echo "echo '${@//\'/\'\\\'\'}' 1>&2" + [[ -n "${@}" ]] && _warn "${@}" echo "false" exit 1 @@ -118,7 +122,12 @@ rpath_ls() { } rpath_get() { - current="$(_get)" && _echo "${current}" + current="$(_get)" || _die 'No rubies found in PATH.' + + [[ $(wc -l <<< "${current}") -gt 1 ]] \ + && _warn 'Warning: multiple rubies found in PATH.' + + _echo "${current}" } rpath_set() { @@ -148,11 +157,11 @@ rpath_clear() { rpath_help() { _echo 'Usage: rpath <command> [args]' _echo - _echo 'Available options:' + _echo 'Commands:' _echo ' ls List all available rubies.' _echo ' get Display currently selected ruby.' _echo ' set Select specified ruby.' - _echo ' clear Clear path of any rpath rubies.' + _echo ' clear Clear path of any rubies.' _echo ' help Display this help information.' } |