diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-06-15 03:27:19 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2014-06-15 03:27:19 -0700 |
commit | bb67f811b3eeb97de56d7d82165305257098947a (patch) | |
tree | 380c1ec9a35ac32cb70b067a3bf8319a56b350f0 | |
parent | 3af36df80d999f36aa5aaff1d9889466c85971e5 (diff) | |
download | rbpm-bb67f811b3eeb97de56d7d82165305257098947a.tar.gz rbpm-bb67f811b3eeb97de56d7d82165305257098947a.tar.xz |
Code organisation.
-rwxr-xr-x | rpath.sh | 42 |
1 files changed, 21 insertions, 21 deletions
@@ -24,7 +24,7 @@ _echo() { echo "echo '${@//\'/\'\\\'\'}'" } -_export_path() { +_export() { echo "export PATH='${PATH//\'/\'\\\'\'}'" echo "hash -r" } @@ -52,16 +52,6 @@ _populate_dirs() { [[ -n "${dirs}" ]] || _die "directory ${RUBIES_PATH} is empty." } -_match() { - if [[ "${1}" =~ ^[0-9]+$ ]]; then - [[ "${2}" == "${1}" ]] && return - else - [[ "${3}" == *"${1}"* ]] && return - fi - - return 1 -} - _populate_selected() { local dir dirs unset selected @@ -81,13 +71,6 @@ _populate_selected() { || _warn 'warning: multiple rubies found in PATH.' } -_set() { - _clear - _echo "Adding ${1}/bin to PATH." - - PATH="${1}/bin:${PATH}" -} - _clear() { local dir dirs cdirs @@ -106,6 +89,22 @@ _clear() { PATH="$(IFS=':'; echo "${cdirs[*]}")" } +_add() { + _echo "Adding ${1}/bin to PATH." + + PATH="${1}/bin:${PATH}" +} + +_match() { + if [[ "${1}" =~ ^[0-9]+$ ]]; then + [[ "${2}" == "${1}" ]] && return + else + [[ "${3}" == *"${1}"* ]] && return + fi + + return 1 +} + rpath_ls() { _populate_dirs _populate_selected @@ -138,8 +137,9 @@ rpath_set() { for dir in "${dirs[@]}"; do if _match "${1}" "$((++counter))" "${dir##*/}"; then - _set "${dir}" - _export_path + _clear + _add "${dir}" + _export return fi @@ -150,7 +150,7 @@ rpath_set() { rpath_clear() { _clear || _die 'no rubies found in PATH.' - _export_path + _export } rpath_help() { |