|
1 | 1 | #!/bin/sh |
2 | | -set -u |
3 | | -# shellcheck disable=1007 |
| 2 | +# shellcheck shell=dash # local variable support |
| 3 | +# shellcheck disable=1007 # spurious warnings when initializing multiple vars |
| 4 | + |
4 | 5 | # ----------------------------------------------------------------------------- |
5 | 6 | # jruby.sh - Start Script for the JRuby interpreter |
| 7 | +# |
| 8 | +# This script handles all Ruby and JRuby command-line arguments, detects the |
| 9 | +# location of the `java` command and JRuby standard library, and launches JRuby |
| 10 | +# using appropriate flags and configuration. A few flags provide additional |
| 11 | +# information: |
| 12 | +# |
| 13 | +# * `jruby --help` for standard options, most based on Ruby flags. |
| 14 | +# * `jruby --properties` to list all JRuby JVM properties for finer-grained |
| 15 | +# configuration. |
| 16 | +# * `jruby --environment` to show the `java` command line that will be run and |
| 17 | +# log output explaining how we got there. |
| 18 | +# |
| 19 | +# This script is intended to be compatible with POSIX shell as much as possible |
| 20 | +# modulo a few small features known to be nonstandard but present in nearly all |
| 21 | +# POSIX shell implementations. We tell shellcheck to treat this source as dash, |
| 22 | +# a version of ash that adds those features and which has been the standard |
| 23 | +# Debian /bin/sh since 2011. |
| 24 | +# |
| 25 | +# See https://en.wikipedia.org/wiki/Almquist_shell#Adoption_in_Debian_and_Ubuntu |
| 26 | +# |
| 27 | +# There are a number of utility functions defined here to cope with the lack of |
| 28 | +# arrays in shell. These functions simulate arrays through other mechanism and |
| 29 | +# ensure we do not damage quoting during argument processing. |
6 | 30 | # ----------------------------------------------------------------------------- |
7 | 31 |
|
| 32 | +# Enable uninitialized variable warnings |
| 33 | +set -u |
| 34 | + |
8 | 35 | # ----- Guarantee local variables are available ------------------------------- |
9 | 36 | if command -v local >/dev/null; then |
10 | 37 | : |
|
138 | 165 | readonly cygwin |
139 | 166 |
|
140 | 167 | use_exec=true |
141 | | -java_opts_from_files="" |
142 | 168 | jdb=false |
143 | 169 |
|
144 | 170 | NO_BOOTCLASSPATH=false |
|
157 | 183 |
|
158 | 184 | java_args="" |
159 | 185 | ruby_args="" |
| 186 | + |
| 187 | +# shellcheck disable=2034 # variable is only read in an eval |
| 188 | +java_opts_from_files="" |
| 189 | +# shellcheck disable=2034 # variable is only read in an eval |
160 | 190 | jdb_args="" |
161 | 191 |
|
162 | 192 | # Force OpenJDK-based JVMs to use /dev/urandom for random number generation |
@@ -507,10 +537,10 @@ else |
507 | 537 | case "${j#"$JRUBY_HOME/lib/"}" in |
508 | 538 | jruby.jar|jruby-complete.jar) continue |
509 | 539 | esac |
510 | | - if [ "$CP" ]; then |
511 | | - CP="$CP$CP_DELIMITER$j" |
512 | | - else |
| 540 | + if [ -z "${CP-}" ]; then |
513 | 541 | CP="$j" |
| 542 | + else |
| 543 | + CP="$CP$CP_DELIMITER$2" |
514 | 544 | fi |
515 | 545 | done |
516 | 546 |
|
|
0 commit comments