Skip to content

Commit

Permalink
[BYTEMAN-352] shell script tools to wrap paths with quotes to not fai…
Browse files Browse the repository at this point in the history
…l when path contains a space character
  • Loading branch information
ochaloup committed Feb 1, 2018
1 parent 01214b5 commit 28ec54b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 45 deletions.
16 changes: 8 additions & 8 deletions bin/bmcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
# use BYTEMAN_HOME to locate installed byteman release
if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
BYTEMAN_HOME=${0%*/bin/bmcheck.sh}
BYTEMAN_HOME="${0%*/bin/bmcheck.sh}"
# allow for rename to plain bmcheck
if [ "$BYTEMAN_HOME" == "$0" ]; then
BYTEMAN_HOME=${0%*/bin/bmcheck}
BYTEMAN_HOME="${0%*/bin/bmcheck}"
fi
if [ "$BYTEMAN_HOME" == "$0" ]; then
echo "Unable to find byteman home"
Expand All @@ -40,19 +40,19 @@ if [ -z "$BYTEMAN_HOME" ]; then
fi

# check that we can find the byteman jar via BYTEMAN_HOME
if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman.jar" ]; then
BYTEMAN_JAR="${BYTEMAN_HOME}/lib/byteman.jar"
else
echo "Cannot locate byteman jar"
exit
fi
CP=${BYTEMAN_JAR}
CP="${BYTEMAN_JAR}"
PACKAGES=""
VERBOSE=""
# for debugging purposes we will also pass through sys prop defines
DEFINES=""
# include application classes upplied via -cp flag and check for -v flag
while [ $# -ne 0 -a ${1#-*} != ${1} ];
while [ $# -ne 0 -a "${1#-*}" != "${1}" ];
do
if [ "$1" == "-cp" ] ; then
CP=${CP}:$2
Expand Down Expand Up @@ -89,7 +89,7 @@ fi
error=0
while [ $# -ne 0 ]
do
if [ ! -f $1 -o ! -r $1 ] ; then
if [ ! -f "$1" -o ! -r "$1" ] ; then
echo "$1 is not a readable file";
error=1
fi
Expand All @@ -103,4 +103,4 @@ fi

# allow for extra java opts via setting BYTEMAN_JAVA_OPTS

java ${BYTEMAN_JAVA_OPTS} -classpath ${CP} $DEFINES org.jboss.byteman.check.TestScript $PACKAGES $VERBOSE $FILES
java ${BYTEMAN_JAVA_OPTS} -classpath "${CP}" $DEFINES org.jboss.byteman.check.TestScript $PACKAGES $VERBOSE $FILES
34 changes: 17 additions & 17 deletions bin/bminstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ function print_java_version()
# use BYTEMAN_HOME to locate installed byteman release
if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
BYTEMAN_HOME=${0%*/bin/bminstall.sh}
BYTEMAN_HOME="${0%*/bin/bminstall.sh}"
# allow for rename to plain bminstall
if [ "$BYTEMAN_HOME" == "$0" ]; then
BYTEMAN_HOME=${0%*/bin/bminstall}
BYTEMAN_HOME="${0%*/bin/bminstall}"
fi
if [ "$BYTEMAN_HOME" == "$0" ]; then
echo "Unable to find byteman home"
Expand All @@ -59,15 +59,15 @@ fi
# check that we can find the byteman jar via BYTEMAN_HOME

# the Install class is in the byteman-install jar
if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman.jar" ]; then
BYTEMAN_JAR="${BYTEMAN_HOME}/lib/byteman.jar"
else
echo "Cannot locate byteman jar"
exit
fi
# the Install class is in the byteman-install jar
if [ -r ${BYTEMAN_HOME}/lib/byteman-install.jar ]; then
BYTEMAN_INSTALL_JAR=${BYTEMAN_HOME}/lib/byteman-install.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman-install.jar" ]; then
BYTEMAN_INSTALL_JAR="${BYTEMAN_HOME}/lib/byteman-install.jar"
else
echo "Cannot locate byteman install jar"
exit
Expand All @@ -83,31 +83,31 @@ if [ $JAVA_VERSION -le 8 ]; then
# this is not currently needed on a Mac
OS=`uname`
if [ ${OS} != "Darwin" ]; then
if [ -r ${JAVA_HOME}/lib/tools.jar ]; then
TOOLS_JAR=${JAVA_HOME}/lib/tools.jar
CP=${BYTEMAN_INSTALL_JAR}:${TOOLS_JAR}
if [ -r "${JAVA_HOME}/lib/tools.jar" ]; then
TOOLS_JAR="${JAVA_HOME}/lib/tools.jar"
CP="${BYTEMAN_INSTALL_JAR}:${TOOLS_JAR}"
else
echo "Cannot locate tools jar"
CP=${BYTEMAN_INSTALL_JAR}
CP="${BYTEMAN_INSTALL_JAR}"
fi
else
if [ $JAVA_VERSION -gt 6 ]; then
if [ -r ${JAVA_HOME}/Classes/classes.jar ]; then
TOOLS_JAR=${JAVA_HOME}/Classes/classes.jar
CP=${BYTEMAN_INSTALL_JAR}:${TOOLS_JAR}
if [ -r "${JAVA_HOME}/Classes/classes.jar" ]; then
TOOLS_JAR="${JAVA_HOME}/Classes/classes.jar"
CP="${BYTEMAN_INSTALL_JAR}:${TOOLS_JAR}"
else
echo "Cannot locate tools jar"
CP=${BYTEMAN_INSTALL_JAR}
CP="${BYTEMAN_INSTALL_JAR}"
fi
else
CP=${BYTEMAN_INSTALL_JAR}
CP="${BYTEMAN_INSTALL_JAR}"
fi
fi
else
CP=${BYTEMAN_INSTALL_JAR}
CP="${BYTEMAN_INSTALL_JAR}"
fi

# allow for extra java opts via setting BYTEMAN_JAVA_OPTS
# attach class will validate arguments

java ${BYTEMAN_JAVA_OPTS} -classpath $CP org.jboss.byteman.agent.install.Install $*
java ${BYTEMAN_JAVA_OPTS} -classpath "$CP" org.jboss.byteman.agent.install.Install $*
11 changes: 6 additions & 5 deletions bin/bmjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ exit
# use BYTEMAN_HOME to locate installed byteman release
if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
BYTEMAN_HOME=${0%*/bin/bmjava.sh}
BYTEMAN_HOME="${0%*/bin/bmjava.sh}"
# allow for rename to plain bmjava
if [ "$BYTEMAN_HOME" == "$0" ]; then
BYTEMAN_HOME=${0%*/bin/bmjava}
BYTEMAN_HOME="${0%*/bin/bmjava}"
fi
if [ "$BYTEMAN_HOME" == "$0" ]; then
echo "Unable to find byteman home"
Expand All @@ -115,8 +115,8 @@ if [ -z "$BYTEMAN_HOME" ]; then
fi

# the byteman jar shouldbe in the lib directory
if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman.jar" ]; then
BYTEMAN_JAR="${BYTEMAN_HOME}/lib/byteman.jar"
else
echo "Cannot locate byteman jar"
exit
Expand Down Expand Up @@ -224,5 +224,6 @@ AGENT_ARGUMENT=${AGENT_PREFIX}=${AGENT_OPTS}

# allow for extra java opts via setting BYTEMAN_JAVA_OPTS

exec java ${BYTEMAN_JAVA_OPTS} ${AGENT_ARGUMENT} ${INJECT_JAVA_LANG_OPTS} $*
set -x
exec java ${BYTEMAN_JAVA_OPTS} "${AGENT_ARGUMENT}" ${INJECT_JAVA_LANG_OPTS} $*

16 changes: 8 additions & 8 deletions bin/bmsubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
# prop= sets system property 'prop' to an empty string
# prop unsets system property 'prop'
#
# -v print the version of the byteman agent and this client
# -v print the version of the byteman agent and this client
#
# use BYTEMAN_HOME to locate installed byteman release
if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
BYTEMAN_HOME=${0%*/bin/bmsubmit.sh}
BYTEMAN_HOME="${0%*/bin/bmsubmit.sh}"
# allow for rename to plain submit
if [ "$BYTEMAN_HOME" == "$0" ]; then
BYTEMAN_HOME=${0%*/bin/bmsubmit}
BYTEMAN_HOME="${0%*/bin/bmsubmit}"
fi
if [ "$BYTEMAN_HOME" == "$0" ]; then
echo "Unable to find byteman home"
Expand All @@ -66,19 +66,19 @@ if [ -z "$BYTEMAN_HOME" ]; then
fi

# the byteman and byteman-submit jars should be in ${BYTEMAN_HOME}/lib
if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman.jar" ]; then
BYTEMAN_JAR="${BYTEMAN_HOME}/lib/byteman.jar"
else
echo "Cannot locate byteman jar"
exit
fi
if [ -r ${BYTEMAN_HOME}/lib/byteman-submit.jar ]; then
BYTEMAN_SUBMIT_JAR=${BYTEMAN_HOME}/lib/byteman-submit.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman-submit.jar" ]; then
BYTEMAN_SUBMIT_JAR="${BYTEMAN_HOME}/lib/byteman-submit.jar"
else
echo "Cannot locate byteman-submit jar"
exit
fi
# allow for extra java opts via setting BYTEMAN_JAVA_OPTS
# Submit class will validate arguments

java ${BYTEMAN_JAVA_OPTS} -classpath ${BYTEMAN_JAR}:${BYTEMAN_SUBMIT_JAR} org.jboss.byteman.agent.submit.Submit $*
java ${BYTEMAN_JAVA_OPTS} -classpath "${BYTEMAN_JAR}":"${BYTEMAN_SUBMIT_JAR}" org.jboss.byteman.agent.submit.Submit $*
14 changes: 7 additions & 7 deletions bin/bytemancheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
# use BYTEMAN_HOME to locate installed byteman release
if [ -z "$BYTEMAN_HOME" ]; then
# use the root of the path to this file to locate the byteman jar
BYTEMAN_HOME=${0%*/bin/bytemancheck.sh}
BYTEMAN_HOME="${0%*/bin/bytemancheck.sh}"
# allow for rename to plain bmjava
if [ "$BYTEMAN_HOME" == "$0" ]; then
BYTEMAN_HOME=${0%*/bin/bytemancheck}
BYTEMAN_HOME="${0%*/bin/bytemancheck}"
fi
if [ "$BYTEMAN_HOME" == "$0" ]; then
echo "Unable to find byteman home"
Expand All @@ -40,8 +40,8 @@ if [ -z "$BYTEMAN_HOME" ]; then
fi

# check that we can find the byteman jar via BYTEMAN_HOME
if [ -r ${BYTEMAN_HOME}/lib/byteman.jar ]; then
BYTEMAN_JAR=${BYTEMAN_HOME}/lib/byteman.jar
if [ -r "${BYTEMAN_HOME}/lib/byteman.jar" ]; then
BYTEMAN_JAR="${BYTEMAN_HOME}/lib/byteman.jar"
else
echo "Cannot locate byteman jar"
exit
Expand All @@ -52,7 +52,7 @@ VERBOSE=""
# for debugging purposes we will also pass through sys prop defines
DEFINES=""
# include application classes upplied via -cp flag and check for -v flag
while [ $# -ne 0 -a ${1#-*} != ${1} ];
while [ $# -ne 0 -a "${1#-*}" != "${1}" ];
do
if [ "$1" == "-cp" ] ; then
CP=${CP}:$2
Expand Down Expand Up @@ -89,7 +89,7 @@ fi
error=0
while [ $# -ne 0 ]
do
if [ ! -f $1 -o ! -r $1 ] ; then
if [ ! -f "$1" -o ! -r "$1" ] ; then
echo "$1 is not a readable file";
error=1
fi
Expand All @@ -103,4 +103,4 @@ fi

# allow for extra java opts via setting BYTEMAN_JAVA_OPTS

java ${BYTEMAN_JAVA_OPTS} -classpath ${CP} $DEFINES org.jboss.byteman.check.TestScript $PACKAGES $VERBOSE $FILES
java ${BYTEMAN_JAVA_OPTS} -classpath "${CP}" $DEFINES org.jboss.byteman.check.TestScript $PACKAGES $VERBOSE $FILES

0 comments on commit 28ec54b

Please sign in to comment.