From 81bb14e181c556e599e20ca6fdc86fdb690b8995 Mon Sep 17 00:00:00 2001 From: James FitzGibbon Date: Fri, 10 May 2013 14:20:16 -0700 Subject: [PATCH] bail out early if readlink is not available readlink comes from GNU coreutils. On systems without it, rbenv used to spin out of control when it didn't have readlink or greadlink available because it would re-exec the frontend script over and over instead of the worker script in libexec. Fixes #389 --- libexec/rbenv | 8 +++++++- libexec/rbenv-hooks | 8 +++++++- libexec/rbenv-init | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/libexec/rbenv b/libexec/rbenv index 0e70361d..2d475857 100755 --- a/libexec/rbenv +++ b/libexec/rbenv @@ -12,8 +12,14 @@ if [ -n "$RBENV_DEBUG" ]; then set -x fi +READLINK=$(type -p greadlink readlink | head -1) +if [ -z "$READLINK" ]; then + echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2 + exit 1 +fi + resolve_link() { - $(type -p greadlink readlink | head -1) "$1" + $READLINK "$1" } abs_dirname() { diff --git a/libexec/rbenv-hooks b/libexec/rbenv-hooks index f81e9af4..86386719 100755 --- a/libexec/rbenv-hooks +++ b/libexec/rbenv-hooks @@ -19,8 +19,14 @@ if [ -z "$RBENV_COMMAND" ]; then exit 1 fi +READLINK=$(type -p greadlink readlink | head -1) +if [ -z "$READLINK" ]; then + echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2 + exit 1 +fi + resolve_link() { - $(type -p greadlink readlink | head -1) $1 + $READLINK "$1" } realpath() { diff --git a/libexec/rbenv-init b/libexec/rbenv-init index 8cbe7df0..7fb7b737 100755 --- a/libexec/rbenv-init +++ b/libexec/rbenv-init @@ -25,8 +25,14 @@ if [ -z "$shell" ]; then shell="$(basename "$SHELL")" fi +READLINK=$(type -p greadlink readlink | head -1) +if [ -z "$READLINK" ]; then + echo "rbenv: cannot find readlink - are you missing GNU coreutils?" >&2 + exit 1 +fi + resolve_link() { - $(type -p greadlink readlink | head -1) $1 + $READLINK "$1" } abs_dirname() {