Fix shell version when invoked from a script

When invoked from a shell script, `$(rbenv init -)` did not get the
shell name correct.
It needs to look at the `args` value from `ps`.

Ref: https://github.com/yyuu/pyenv/issues/373
This commit is contained in:
Daniel Hahler 2015-05-10 16:03:06 +02:00 committed by Mislav Marohnić
parent f9d8b551dc
commit 32030e2ed9

View file

@ -33,7 +33,7 @@ done
shell="$1"
if [ -z "$shell" ]; then
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
shell="$(ps -p "$PPID" -o 'args=' 2>/dev/null || true)"
shell="${shell##-}"
shell="${shell%% *}"
shell="${shell:-$SHELL}"