59b5147a34
Includes some fixes for problems reported by Yannick Francois and Jeremy Evans. Thanks guys!
188 lines
6.4 KiB
Plaintext
188 lines
6.4 KiB
Plaintext
$OpenBSD: patch-bin_jruby,v 1.2 2008/07/21 11:17:33 bernd Exp $
|
|
--- bin/jruby.orig Sat Jul 19 07:12:22 2008
|
|
+++ bin/jruby Sun Jul 20 14:43:56 2008
|
|
@@ -1,4 +1,4 @@
|
|
-#!/bin/bash
|
|
+#!/bin/sh
|
|
# -----------------------------------------------------------------------------
|
|
# jruby.sh - Start Script for the JRuby interpreter
|
|
#
|
|
@@ -20,6 +20,9 @@ esac
|
|
|
|
# ----- Verify and Set Required Environment Variables -------------------------
|
|
|
|
+JAVA_HOME=$(javaPathHelper -h jruby)
|
|
+JRUBY_LIBDIR=${JRUBY_LIBDIR}
|
|
+
|
|
## resolve links - $0 may be a link to home
|
|
PRG=$0
|
|
progname=`basename "$0"`
|
|
@@ -34,12 +37,14 @@ while [ -h "$PRG" ] ; do
|
|
fi
|
|
done
|
|
|
|
-JRUBY_HOME_1=`dirname "$PRG"` # the ./bin dir
|
|
-JRUBY_HOME=`dirname "$JRUBY_HOME_1"` # the . dir
|
|
-# When . == bin and . is in path, need to make home be .. (JRUBY-2699)
|
|
-#if [ $JRUBY_HOME = '.' ] ; then
|
|
-# JRUBY_HOME='..'
|
|
-#fi
|
|
+if [ -z "$JRUBY_HOME" ]; then
|
|
+ JRUBY_HOME_1=`dirname "$PRG"` # the ./bin dir
|
|
+ JRUBY_HOME=`dirname "$JRUBY_HOME_1"` # the . dir
|
|
+ # When . == bin and . is in path, need to make home be .. (JRUBY-2699)
|
|
+ #if [ $JRUBY_HOME = '.' ] ; then
|
|
+ # JRUBY_HOME='..'
|
|
+ #fi
|
|
+fi
|
|
|
|
if [ -z "$JRUBY_OPTS" ] ; then
|
|
JRUBY_OPTS=""
|
|
@@ -61,7 +66,7 @@ JRUBY_SHELL=/bin/sh
|
|
CP_DELIMETER=":"
|
|
|
|
# add jruby jars for command-line execution
|
|
-for j in "$JRUBY_HOME"/lib/jruby*.jar; do
|
|
+for j in "$JRUBY_LIBDIR"/jruby*.jar; do
|
|
if [ "$JRUBY_CP" ]; then
|
|
JRUBY_CP="$JRUBY_CP$CP_DELIMETER$j"
|
|
else
|
|
@@ -107,17 +112,18 @@ JAVA_VM=-client
|
|
|
|
# Split out any -J argument for passing to the JVM.
|
|
# Scanning for args is aborted by '--'.
|
|
-declare -a java_args
|
|
-declare -a ruby_args
|
|
+java_args=
|
|
+ruby_args=
|
|
while [ $# -gt 0 ]
|
|
do
|
|
case "$1" in
|
|
# Stuff after '-J' in this argument goes to JVM
|
|
-J*)
|
|
- val=${1:2}
|
|
- if [ "${val:0:4}" = "-Xmx" ]; then
|
|
+ val=$(expr "$1" : "-J\(.*\)")
|
|
+ jvm_arg=$(expr "$val" : "\(....\)")
|
|
+ if [ "$jvm_arg" = "-Xmx" ]; then
|
|
JAVA_MEM=$val
|
|
- elif [ "${val:0:4}" = "-Xss" ]; then
|
|
+ elif [ "$jvm_arg" = "-Xss" ]; then
|
|
JAVA_STACK=$val
|
|
elif [ "${val}" = "" ]; then
|
|
$JAVA_CMD -help
|
|
@@ -128,16 +134,16 @@ do
|
|
echo "(Prepend -J in front of these options when using 'jruby' command)"
|
|
exit
|
|
else
|
|
- if [ "${val:0:3}" = "-ea" ]; then
|
|
+ if [ "$(expr "$val" : "\(...\)")" = "-ea" ]; then
|
|
VERIFY_JRUBY="yes"
|
|
fi
|
|
- java_args=("${java_args[@]}" "${1:2}")
|
|
+ java_args="$java_args $jvm_arg"
|
|
fi
|
|
;;
|
|
# Match switches that take an argument
|
|
- -e|-I|-S) ruby_args=("${ruby_args[@]}" "$1" "$2"); shift ;;
|
|
+ -e|-I|-S) ruby_args="$ruby_args $1 \"$2\""; shift ;;
|
|
# Match same switches with argument stuck together
|
|
- -e*|-I*|-S*) ruby_args=("${ruby_args[@]}" "$1" ) ;;
|
|
+ -e*|-I*|-S*) ruby_args="$ruby_args \"$1\"" ;;
|
|
# Run with the instrumented profiler: http://jiprof.sourceforge.net/
|
|
--profile)
|
|
PROFILE_ARGS="-javaagent:$JRUBY_HOME/lib/profile.jar -Dprofile.properties=$JRUBY_HOME/lib/profile-ruby.properties"
|
|
@@ -150,7 +156,7 @@ do
|
|
;;
|
|
# Run with JMX management enabled
|
|
--manage)
|
|
- java_args=("${java_args[@]}" "-Dcom.sun.management.jmxremote") ;;
|
|
+ java_args="$java_args -Dcom.sun.management.jmxremote" ;;
|
|
# Run under JDB
|
|
--jdb)
|
|
if [ -z "$JAVA_HOME" ] ; then
|
|
@@ -166,15 +172,15 @@ do
|
|
--server)
|
|
JAVA_VM=-server ;;
|
|
--sample)
|
|
- java_args=("${java_args[@]}" "-Xprof") ;;
|
|
+ java_args="$java_args -Xprof" ;;
|
|
--1.9)
|
|
- java_args=("${java_args[@]}" "-Djruby.compat.version=RUBY1_9") ;;
|
|
+ java_args="$java_args -Djruby.compat.version=RUBY1_9" ;;
|
|
--1.8)
|
|
- java_args=("${java_args[@]}" "-Djruby.compat.version=RUBY1_8") ;;
|
|
+ java_args="$java_args -Djruby.compat.version=RUBY1_8" ;;
|
|
# Abort processing on the double dash
|
|
--) break ;;
|
|
# Other opts go to ruby
|
|
- -*) ruby_args=("${ruby_args[@]}" "$1") ;;
|
|
+ -*) ruby_args="$ruby_args $1" ;;
|
|
# Abort processing on first non-opt arg
|
|
*) break ;;
|
|
esac
|
|
@@ -182,13 +188,15 @@ do
|
|
done
|
|
|
|
# Add a property to report memory max
|
|
-JAVA_OPTS="$JAVA_OPTS $JAVA_VM -Djruby.memory.max=${JAVA_MEM:4} -Djruby.stack.max=${JAVA_STACK:4}"
|
|
+java_mem_max=$(expr "$JAVA_MEM" : "....\(.*\)")
|
|
+java_stack_max=$(expr "$JAVA_STACK" : "....\(.*\)")
|
|
+JAVA_OPTS="$JAVA_OPTS $JAVA_VM -Djruby.memory.max=$java_mem_max -Djruby.stack.max=$java_stack_max"
|
|
|
|
# Append the rest of the arguments
|
|
-ruby_args=("${ruby_args[@]}" "$@")
|
|
+ruby_args="$ruby_args $@"
|
|
|
|
# Put the ruby_args back into the position arguments $1, $2 etc
|
|
-set -- "${ruby_args[@]}"
|
|
+set -- "$ruby_args"
|
|
|
|
JAVA_OPTS="$JAVA_OPTS $JAVA_MEM $JAVA_STACK"
|
|
|
|
@@ -196,11 +204,13 @@ if $cygwin; then
|
|
JRUBY_HOME=`cygpath --mixed "$JRUBY_HOME"`
|
|
JRUBY_SHELL=`cygpath --mixed "$JRUBY_SHELL"`
|
|
|
|
- if [[ ( "${1:0:1}" = "/" ) && ( ( -f "$1" ) || ( -d "$1" )) ]]; then
|
|
- win_arg=`cygpath -w "$1"`
|
|
- shift
|
|
- win_args=("$win_arg" "$@")
|
|
- set -- "${win_args[@]}"
|
|
+ if [ "$(expr "$1" : "\(.\).*")" = "/" ]; then
|
|
+ if [ -f "$1" -o -d "$1" ]; then
|
|
+ win_arg=`cygpath -w "$1"`
|
|
+ shift
|
|
+ win_args="$win_arg $@"
|
|
+ set -- "$win_args"
|
|
+ fi
|
|
fi
|
|
fi
|
|
|
|
@@ -209,9 +219,9 @@ if [ "$VERIFY_JRUBY" != "" ]; then
|
|
echo "Running with instrumented profiler"
|
|
fi
|
|
|
|
- $JAVA_CMD $PROFILE_ARGS $JAVA_OPTS "${java_args[@]}" -classpath "$JRUBY_CP$CP_DELIMETER$CP$CP_DELIMETER$CLASSPATH" \
|
|
- "-Djruby.home=$JRUBY_HOME" \
|
|
- "-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
|
|
+ eval $JAVA_CMD $PROFILE_ARGS $JAVA_OPTS "$java_args" -classpath "$JRUBY_CP$CP_DELIMETER$CP$CP_DELIMETER$CLASSPATH" \
|
|
+ "-Djruby.home=$JRUBY_LIBDIR" \
|
|
+ "-Djruby.lib=$JRUBY_LIBDIR" -Djruby.script=jruby \
|
|
"-Djruby.shell=$JRUBY_SHELL" \
|
|
org.jruby.Main $JRUBY_OPTS "$@"
|
|
|
|
@@ -221,9 +231,9 @@ if [ "$VERIFY_JRUBY" != "" ]; then
|
|
cat profile.txt
|
|
fi
|
|
else
|
|
- exec "$JAVA_CMD" $JAVA_OPTS "${java_args[@]}" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMETER$CLASSPATH" \
|
|
- "-Djruby.home=$JRUBY_HOME" \
|
|
- "-Djruby.lib=$JRUBY_HOME/lib" -Djruby.script=jruby \
|
|
+ eval exec "$JAVA_CMD" $JAVA_OPTS "$java_args" -Xbootclasspath/a:"$JRUBY_CP" -classpath "$CP$CP_DELIMETER$CLASSPATH" \
|
|
+ "-Djruby.home=$JRUBY_LIBDIR" \
|
|
+ "-Djruby.lib=$JRUBY_LIBDIR" -Djruby.script=jruby \
|
|
"-Djruby.shell=$JRUBY_SHELL" \
|
|
org.jruby.Main $JRUBY_OPTS "$@"
|
|
fi
|