[chruby] properly quote variable expansion

to prevent word splitting
This commit is contained in:
Michal Cichra 2016-10-25 12:45:44 +02:00
commit edf38111d9
No known key found for this signature in database
GPG key ID: 8F4BAE64224DE335

View file

@ -30,7 +30,9 @@ _ruby-install-installed() {
# Simple definition completer for ruby-build # Simple definition completer for ruby-build
if _ruby-build_installed; then if _ruby-build_installed; then
_ruby-build() { compadd $(ruby-build --definitions) } _ruby-build() {
compadd $(ruby-build --definitions)
}
compdef _ruby-build ruby-build compdef _ruby-build ruby-build
fi fi
@ -41,21 +43,21 @@ _source_from_omz_settings() {
zstyle -s :omz:plugins:chruby path _chruby_path zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto zstyle -s :omz:plugins:chruby auto _chruby_auto
if [[ -r ${_chruby_path} ]]; then if [[ -r "${_chruby_path}" ]]; then
source ${_chruby_path} source "${_chruby_path}"
fi fi
if [[ -r ${_chruby_auto} ]]; then if [[ -r "${_chruby_auto}" ]]; then
source ${_chruby_auto} source "${_chruby_auto}"
fi fi
} }
function () { function () {
local _chruby_homebrew_prefix=$(brew --prefix chruby) &> /dev/null local _chruby_homebrew_prefix="$(brew --prefix chruby) &> /dev/null"
if _homebrew-installed && [ -r ${_chruby_homebrew_prefix} ] ; then if _homebrew-installed && [ -r "${_chruby_homebrew_prefix}" ] ; then
source ${_chruby_homebrew_prefix}/share/chruby/chruby.sh source "${_chruby_homebrew_prefix}/share/chruby/chruby.sh"
source ${_chruby_homebrew_prefix}/share/chruby/auto.sh source "${_chruby_homebrew_prefix}/share/chruby/auto.sh"
elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then
source /usr/local/share/chruby/chruby.sh source /usr/local/share/chruby/chruby.sh
source /usr/local/share/chruby/auto.sh source /usr/local/share/chruby/auto.sh
@ -69,9 +71,9 @@ function ensure_chruby() {
} }
function current_ruby() { function current_ruby() {
local _ruby="$(chruby |grep \* |tr -d '* ')" local _ruby="$(chruby | grep \* | tr -d '* ')"
if [[ $(chruby |grep -c \*) -eq 1 ]]; then if [[ -n "${_ruby}" ]]; then
echo ${_ruby} echo "${_ruby}"
else else
echo "system" echo "system"
fi fi