Browse Source

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 <patrick.luby@sun.com>
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273200 13f79535-47bb-0310-9956-ffa450edef68
master
Costin Manolache 23 years ago
parent
commit
8d673eadc0
2 changed files with 16 additions and 19 deletions
  1. +15
    -18
      src/script/ant
  2. +1
    -1
      src/script/antRun

+ 15
- 18
src/script/ant View File

@@ -44,20 +44,18 @@ if [ -z "$ANT_HOME" ] ; then
fi fi


## resolve links - $0 may be a link to ant's home ## resolve links - $0 may be a link to ant's home
PRG=$0
progname=`basename $0`
PRG="$0"
progname=`basename "$0"`
saveddir=`pwd` saveddir=`pwd`


# need this for relative symlinks # need this for relative symlinks
cd `dirname $PRG`
while [ -h "$PRG" ] ; do while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"` ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'` link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then if expr "$link" : '.*/.*' > /dev/null; then
PRG="$link" PRG="$link"
else else
PRG="`dirname $PRG`/$link"
PRG=`dirname "$PRG"`"/$link"
fi fi
done done
@@ -80,7 +78,7 @@ if $cygwin ; then
fi fi


# set ANT_LIB location # set ANT_LIB location
ANT_LIB=${ANT_HOME}/lib
ANT_LIB="${ANT_HOME}/lib"


if [ -z "$JAVACMD" ] ; then if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then if [ -n "$JAVA_HOME" ] ; then
@@ -107,18 +105,18 @@ fi


# in rpm_mode get ant/optional/xml parser&api from JAVALIBDIR # in rpm_mode get ant/optional/xml parser&api from JAVALIBDIR
if $rpm_mode; then if $rpm_mode; then
JAVALIBDIR=/usr/share/java
JAVALIBDIR="/usr/share/java"
for i in ant ant-optional jaxp_parser xml_apis for i in ant ant-optional jaxp_parser xml_apis
do do
if [ -z "$LOCALCLASSPATH" ] ; then if [ -z "$LOCALCLASSPATH" ] ; then
LOCALCLASSPATH=$JAVALIBDIR/$i.jar
LOCALCLASSPATH="$JAVALIBDIR/$i.jar"
else else
LOCALCLASSPATH="$JAVALIBDIR/$i.jar":"$LOCALCLASSPATH"
LOCALCLASSPATH="$JAVALIBDIR/$i.jar:$LOCALCLASSPATH"
fi fi
done done


# in rpm mode ant/lib is in /usr/share/java/ant # in rpm mode ant/lib is in /usr/share/java/ant
ANT_LIB=${JAVALIBDIR}/ant
ANT_LIB="${JAVALIBDIR}/ant"


fi fi


@@ -127,11 +125,11 @@ for i in "${ANT_LIB}"/*.jar
do do
# if the directory is empty, then it will return the input string # if the directory is empty, then it will return the input string
# this is stupid, so case for it # this is stupid, so case for it
if [ "$i" != "${ANT_LIB}/*.jar" ] ; then
if [ -f "$i" ] ; then
if [ -z "$LOCALCLASSPATH" ] ; then if [ -z "$LOCALCLASSPATH" ] ; then
LOCALCLASSPATH=$i
LOCALCLASSPATH="$i"
else else
LOCALCLASSPATH="$i":"$LOCALCLASSPATH"
LOCALCLASSPATH="$i:$LOCALCLASSPATH"
fi fi
fi fi
done done
@@ -148,10 +146,10 @@ if [ -n "$JAVA_HOME" ] ; then
# OSX hack to make Ant work with jikes # OSX hack to make Ant work with jikes
if $darwin ; then if $darwin ; then
OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes" 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 do
JIKESPATH=$JIKESPATH:$i
JIKESPATH="$JIKESPATH:$i"
done done
fi fi
fi fi
@@ -167,7 +165,6 @@ if [ -n "$JIKESPATH" ] ; then
if $cygwin ; then if $cygwin ; then
JIKESPATH=`cygpath --path --windows "$JIKESPATH"` JIKESPATH=`cygpath --path --windows "$JIKESPATH"`
fi fi
ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
fi fi


# Allow Jikes support (off by default) # Allow Jikes support (off by default)
@@ -184,4 +181,4 @@ if $cygwin; then
ANT_OPTS="$ANT_OPTS -Dcygwin.user.home="`cygpath --path --windows "$HOME"` ANT_OPTS="$ANT_OPTS -Dcygwin.user.home="`cygpath --path --windows "$HOME"`
fi 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 "$@"

+ 1
- 1
src/script/antRun View File

@@ -9,4 +9,4 @@ CMD="$2"
shift shift
shift shift


exec $CMD "$@"
exec "$CMD" "$@"

Loading…
Cancel
Save