1
0
mirror of https://github.com/pyenv/pyenv.git synced 2025-11-18 08:13:46 -05:00

reliably detect parent shell in rbenv init

`$SHELL` variable is a terrible way of detecting the current shell
because it's not even supposed to reflect the current shell; it's meant
for keeping the value of the default shell for programs to start.

If an explicit `<shell>` argument wasn't passed to `rbenv init`, it
tries to detect the shell by getting the name of its parent process. If
this fails, it falls back on the value of `$SHELL` as before.

Furthermore, `rbenv init` will set the RBENV_SHELL variable in the
current shell to the value of the detected shell so that `sh-shell` and
`sh-rehash` commands don't have to repeat the detection.
This commit is contained in:
Mislav Marohnić
2013-09-28 18:43:39 +02:00
parent ff23666d56
commit 878bd87328
6 changed files with 34 additions and 17 deletions

View File

@@ -101,14 +101,14 @@ SH
@test "sh-rehash in bash" {
create_executable "2.0" "ruby"
SHELL=/bin/bash run rbenv-sh-rehash
RBENV_SHELL=bash run rbenv-sh-rehash
assert_success "hash -r 2>/dev/null || true"
assert [ -x "${RBENV_ROOT}/shims/ruby" ]
}
@test "sh-rehash in fish" {
create_executable "2.0" "ruby"
SHELL=/usr/bin/fish run rbenv-sh-rehash
RBENV_SHELL=fish run rbenv-sh-rehash
assert_success "hash -r 2>/dev/null ; or true"
assert [ -x "${RBENV_ROOT}/shims/ruby" ]
}