Skip to content

Commit

Permalink
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -200,22 +200,13 @@ JAVA_CLASS_NGSERVER=org.jruby.main.NailServerMain

# Split out any -J argument for passing to the JVM.
# Scanning for args is aborted by '--'.

# Wrap $JRUBY_OPTS in "" to preserve options with spaces. However, wrapping in "" will ensure there's always a value.
# We only want to add $JRUBY_OPTS to $@ if it's non-empty, so check that first.
if [ "x$JRUBY_OPTS" != x ]; then
set -- "$JRUBY_OPTS" "$@"
fi

set -- $JRUBY_OPTS "$@"
while [ $# -gt 0 ]
do
# String leading and trailing whitespace from the option.
option="$(echo -e "$1" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"

case "$option" in
case "$1" in
# Stuff after '-J' in this argument goes to JVM
-J*)
val=${option:2}
val=${1:2}
if [ "${val:0:4}" = "-Xmx" ]; then
JAVA_MEM=$val
elif [ "${val:0:4}" = "-Xms" ]; then
@@ -224,11 +215,11 @@ do
JAVA_STACK=$val
elif [ "${val}" = "" ]; then
$JAVACMD -help
echo "(Prepend -J in front of these options when using 'jruby' command)"
echo "(Prepend -J in front of these options when using 'jruby' command)"
exit
elif [ "${val}" = "-X" ]; then
$JAVACMD -X
echo "(Prepend -J in front of these options when using 'jruby' command)"
echo "(Prepend -J in front of these options when using 'jruby' command)"
exit
elif [ "${val}" = "-classpath" ]; then
CP="$CP$CP_DELIMITER$2"
@@ -244,22 +235,15 @@ do
elif [ "${val:0:16}" = "-Dfile.encoding=" ]; then
JAVA_ENCODING=$val
fi

# Check if the option has an embedded space and the option is not quoted (via a check of the last char in
# the option). NB: ": -1" is not a typo. If you delete that space character things will break.
if [[ "$option" =~ ' ' && (${option: -1} != "'" && ${option: -1} != '"') ]]; then
java_args=("${java_args[@]}" "'${option:2}'")
else
java_args=("${java_args[@]}" "${option:2}")
fi
java_args=("${java_args[@]}" "${1:2}")
fi
;;
# Pass -X... and -X? search options through
-X*\.\.\.|-X*\?)
ruby_args=("${ruby_args[@]}" "$1") ;;
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X*)
val=${option:2}
val=${1:2}
if expr "$val" : '.*[.]' > /dev/null; then
java_args=("${java_args[@]}" "-Djruby.${val}")
else
@@ -287,7 +271,7 @@ do
else
JAVACMD="$JAVA_HOME/bin/jdb"
fi
fi
fi
java_args=("${java_args[@]}" "-sourcepath" "$JRUBY_HOME/lib/ruby/1.9:.")
JRUBY_OPTS=("${JRUBY_OPTS[@]}" "-X+C") ;;
--client)
@@ -412,7 +396,7 @@ else

exit $JRUBY_STATUS
else
eval "$JAVACMD" $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH" \
exec "$JAVACMD" $JAVA_OPTS "$JFFI_OPTS" "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMITER$CLASSPATH" \
"-Djruby.home=$JRUBY_HOME" \
"-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
"-Djruby.shell=$JRUBY_SHELL" \

0 comments on commit 351d7b6

Please sign in to comment.