From a6d593934f34d35642cdc8a79421404560f89fe1 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 13 Feb 2012 15:54:54 -0500 Subject: [PATCH] falling back if which is not a valid command. --- examples/custom_overrides/fred/java_profile.sh | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/examples/custom_overrides/fred/java_profile.sh b/examples/custom_overrides/fred/java_profile.sh index 69cb9308..423e99d5 100644 --- a/examples/custom_overrides/fred/java_profile.sh +++ b/examples/custom_overrides/fred/java_profile.sh @@ -6,6 +6,17 @@ ############################ +function whichable() +{ + to_find="$1"; shift + which which &>/dev/null + if [ $? -ne 0 ]; then + # there is no which command here. we produce nothing due to this. + echo + fi + echo $(which $to_find) +} + # this reports when we have totally failed to figure out where a folder # is actually located on the machine. function intuition_failure() @@ -63,7 +74,7 @@ if [ ! -d "$JAVA_HOME" ]; then JAVA_BIN_PIECE=Commands fi # last thing is to tell them we couldn't find it. -if [ ! -d "$JAVA_HOME" -a -z "$(which java 2>/dev/null)" ]; then +if [ ! -d "$JAVA_HOME" -a -z "$(whichable java 2>/dev/null)" ]; then intuition_failure JAVA_HOME unset JAVA_BIN_PIECE fi @@ -94,7 +105,7 @@ if [ ! -d "$ECLIPSE_DIR" ]; then ECLIPSE_DIR="/e/tools/eclipse" fi # final option is to whine. -if [ ! -d "$ECLIPSE_DIR" -a -z "$(which eclipse 2>/dev/null)" ]; then +if [ ! -d "$ECLIPSE_DIR" -a -z "$(whichable eclipse 2>/dev/null)" ]; then intuition_failure ECLIPSE_DIR fi -- 2.34.1