From 1a6bada94cad7605188daafca8106a975c193979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Thu, 2 Jan 2014 22:36:03 +0100 Subject: [PATCH] Fix detecting parent shell on OpenBSD and Cygwin 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 --- libexec/rbenv-init | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-init b/libexec/rbenv-init index a3292d663f..a28b7fc4c4 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -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