sstephenson/rbenv — pull request #453 by mislav (2013-09-28 17:15:55+00:00)
Title: Reliably detect parent shell in `rbenv init`

This addresses one of the most common issues that people have with rbenv: unreliable detection of their shell type when they eval the output of `rbenv init -`. #435 #260 #239 #383 #251 #185 #59

`$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 `` 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 also enables spawning interactive subshells (e.g. zsh within bash) and having rbenv Just Work™.

/cc @sstephenson @josh
/ht @envygeeks