gerrit.sh: Support spaces in JAVA_HOME

Mac OS X may have spaces in its JAVA_HOME path, so support those by
avoiding contexts where it isn't properly quoted or protected from the
shell splitting rules.

Change-Id: I228c3e6456009ffb4adec7d1a385ea0d333258d0
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce 2011-04-05 14:20:02 -04:00
parent 04e7cfe8f0
commit 64b1446e26

View File

@ -269,8 +269,11 @@ if test -z "$JAVA_HOME" ; then
echo "** INFO: Using $JAVA" echo "** INFO: Using $JAVA"
fi fi
if test -z "$JAVA" -a -n "$JAVA_HOME" ; then if test -z "$JAVA" \
test -x $JAVA_HOME/bin/java -a ! -d $JAVA_HOME/bin/java && JAVA=$JAVA_HOME/bin/java -a -n "$JAVA_HOME" \
-a -x "$JAVA_HOME/bin/java" \
-a ! -d "$JAVA_HOME/bin/java" ; then
JAVA="$JAVA_HOME/bin/java"
fi fi
if test -z "$JAVA" ; then if test -z "$JAVA" ; then
@ -354,10 +357,11 @@ if test -x /usr/bin/perl ; then
# If possible, use Perl to mask the name of the process so its # If possible, use Perl to mask the name of the process so its
# something specific to us rather than the generic 'java' name. # something specific to us rather than the generic 'java' name.
# #
export JAVA
RUN_EXEC=/usr/bin/perl RUN_EXEC=/usr/bin/perl
RUN_Arg1=-e RUN_Arg1=-e
RUN_Arg2='$x=shift @ARGV;exec $x @ARGV;die $!' RUN_Arg2='$x=$ENV{JAVA};exec $x @ARGV;die $!'
RUN_Arg3="-- $JAVA GerritCodeReview" RUN_Arg3='-- GerritCodeReview'
else else
RUN_EXEC=$JAVA RUN_EXEC=$JAVA
RUN_Arg1= RUN_Arg1=