Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bin/chruby-exec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ fi

command="chruby $(printf "%q " "${argv[@]}") && $(printf "%q " "$@")"

abs_shell=$(readlink -f $SHELL)
if [[ ${abs_shell##*/} == "dash" ]]; then
if which bash &> /dev/null; then
SHELL="bash"
elif which zsh &> /dev/null; then
SHELL="zsh"
fi
fi

if [[ -t 0 ]]; then exec "$SHELL" -i -l -c "$command"
else exec "$SHELL" -l -c "$command"
fi
9 changes: 9 additions & 0 deletions test/chruby_exec_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,13 @@ function test_chruby_exec()
assertEquals "did change the ruby" "$test_ruby_version" "$ruby_version"
}

function test_chruby_exec_dash()
{
SHELL="/bin/dash"
local ruby_version=$(chruby-exec "$test_ruby_version" -- ruby -e "print RUBY_VERSION")

assertEquals "did change the ruby despite dash" "$test_ruby_version" "$ruby_version"
}


SHUNIT_PARENT=$0 . $SHUNIT2