From 8d673eadc08335e5a86ca859ac4bc164d15c48d6 Mon Sep 17 00:00:00 2001 From: Costin Manolache Date: Thu, 8 Aug 2002 17:07:48 +0000 Subject: [PATCH] Submited the patch from Patrick. 1. Removes the extraneous "cd `dirname $PRG`" line that causes the script to break when Ant is invoked with from a relative path (i.e. ../jakarta-ant/bin/ant). 2. Properly quote all environment variables that may contain paths. The script would break if any of these environment variables contained paths with spaces in them (a common occurrence on Windows). 3. Invoke Java using the "exec" shell command. There really is no need to create a child process to run the JVM and by using the "exec" command, there is less chance that killing the script will fail to kill Ant. PR: Obtained from: Submitted by: Patrick Luby Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273200 13f79535-47bb-0310-9956-ffa450edef68 --- src/script/ant | 33 +++++++++++++++------------------ src/script/antRun | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/src/script/ant b/src/script/ant index 031a4fa08..dd7e8d8ce 100644 --- a/src/script/ant +++ b/src/script/ant @@ -44,20 +44,18 @@ if [ -z "$ANT_HOME" ] ; then fi ## resolve links - $0 may be a link to ant's home - PRG=$0 - progname=`basename $0` + PRG="$0" + progname=`basename "$0"` saveddir=`pwd` # need this for relative symlinks - cd `dirname $PRG` - while [ -h "$PRG" ] ; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else - PRG="`dirname $PRG`/$link" + PRG=`dirname "$PRG"`"/$link" fi done @@ -80,7 +78,7 @@ if $cygwin ; then fi # set ANT_LIB location -ANT_LIB=${ANT_HOME}/lib +ANT_LIB="${ANT_HOME}/lib" if [ -z "$JAVACMD" ] ; then if [ -n "$JAVA_HOME" ] ; then @@ -107,18 +105,18 @@ fi # in rpm_mode get ant/optional/xml parser&api from JAVALIBDIR if $rpm_mode; then - JAVALIBDIR=/usr/share/java + JAVALIBDIR="/usr/share/java" for i in ant ant-optional jaxp_parser xml_apis do if [ -z "$LOCALCLASSPATH" ] ; then - LOCALCLASSPATH=$JAVALIBDIR/$i.jar + LOCALCLASSPATH="$JAVALIBDIR/$i.jar" else - LOCALCLASSPATH="$JAVALIBDIR/$i.jar":"$LOCALCLASSPATH" + LOCALCLASSPATH="$JAVALIBDIR/$i.jar:$LOCALCLASSPATH" fi done # in rpm mode ant/lib is in /usr/share/java/ant -ANT_LIB=${JAVALIBDIR}/ant +ANT_LIB="${JAVALIBDIR}/ant" fi @@ -127,11 +125,11 @@ for i in "${ANT_LIB}"/*.jar do # if the directory is empty, then it will return the input string # this is stupid, so case for it - if [ "$i" != "${ANT_LIB}/*.jar" ] ; then + if [ -f "$i" ] ; then if [ -z "$LOCALCLASSPATH" ] ; then - LOCALCLASSPATH=$i + LOCALCLASSPATH="$i" else - LOCALCLASSPATH="$i":"$LOCALCLASSPATH" + LOCALCLASSPATH="$i:$LOCALCLASSPATH" fi fi done @@ -148,10 +146,10 @@ if [ -n "$JAVA_HOME" ] ; then # OSX hack to make Ant work with jikes if $darwin ; then OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes" - if [ -d ${OSXHACK} ] ; then - for i in ${OSXHACK}/*.jar + if [ -d "${OSXHACK}" ] ; then + for i in "${OSXHACK}"/*.jar do - JIKESPATH=$JIKESPATH:$i + JIKESPATH="$JIKESPATH:$i" done fi fi @@ -167,7 +165,6 @@ if [ -n "$JIKESPATH" ] ; then if $cygwin ; then JIKESPATH=`cygpath --path --windows "$JIKESPATH"` fi - ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH" fi # Allow Jikes support (off by default) @@ -184,4 +181,4 @@ if $cygwin; then ANT_OPTS="$ANT_OPTS -Dcygwin.user.home="`cygpath --path --windows "$HOME"` fi -"$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@" +exec "$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" -Djikes.class.path="$JIKESPATH" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@" diff --git a/src/script/antRun b/src/script/antRun index cf9272ef2..98c5ef5c1 100644 --- a/src/script/antRun +++ b/src/script/antRun @@ -9,4 +9,4 @@ CMD="$2" shift shift -exec $CMD "$@" +exec "$CMD" "$@"