Skip to content

Commit

Permalink
Fix detecting parent shell on OpenBSD and Cygwin
Browse files Browse the repository at this point in the history
It seems that "comm" header can't be relied on cross-platform, but that
"ucomm" is more portable. I have no idea whether it's the right value to
use here, but it seems to be doing the job.

Also strip trailing whitespace because OpenBSD 5.4 `ps` output is padded
with spaces for some reason.

Fixes #489
  • Loading branch information
mislav committed Jan 2, 2014
1 parent eda535a commit 1a6bada
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libexec/rbenv-init
Expand Up @@ -22,8 +22,9 @@ done

shell="$1"
if [ -z "$shell" ]; then
shell="$(ps c -p $(ps -p $$ -o 'ppid=' 2>/dev/null) -o 'comm=' 2>/dev/null || true)"
shell="$(ps c -p "$PPID" -o 'ucomm=' 2>/dev/null || true)"
shell="${shell##-}"
shell="${shell%% *}"
shell="$(basename "${shell:-$SHELL}")"
fi

Expand Down

0 comments on commit 1a6bada

Please sign in to comment.