From 3efdf6a2430b72bc5f6fe2c25752619d28fd9661 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Sun, 14 Aug 2011 14:16:26 -0500 Subject: [PATCH] Guard against nonexistent entries in $PATH --- libexec/rbenv-which | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libexec/rbenv-which b/libexec/rbenv-which index 5e605628..0f8fd2c5 100755 --- a/libexec/rbenv-which +++ b/libexec/rbenv-which @@ -2,6 +2,10 @@ set -e expand_path() { + if [ ! -d "$1" ]; then + return 1 + fi + local cwd="$(pwd)" cd "$1" pwd @@ -14,7 +18,7 @@ remove_from_path() { for path in ${PATH//:/$'\n'}; do path="$(expand_path "$path" || true)" - if [ "$path" != "$path_to_remove" ]; then + if [ -n "$path" ] && [ "$path" != "$path_to_remove" ]; then result="${result}${path}:" fi done