Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,19 @@ jobs:
env:
PHASE: 'package -Ptest'

jruby-shell-check:
runs-on: ubuntu-latest

name: shellcheck jruby.sh

steps:
- name: checkout
uses: actions/checkout@v3
- name: install shellcheck
run: sudo apt install shellcheck
- name: run shellcheck
run: shellcheck bin/jruby.sh

rake-test-wip-8:
runs-on: ubuntu-latest

Expand Down
42 changes: 36 additions & 6 deletions bin/jruby.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
#!/bin/sh
set -u
# shellcheck disable=1007
# shellcheck shell=dash # local variable support
# shellcheck disable=1007 # spurious warnings when initializing multiple vars

# -----------------------------------------------------------------------------
# jruby.sh - Start Script for the JRuby interpreter
#
# This script handles all Ruby and JRuby command-line arguments, detects the
# location of the `java` command and JRuby standard library, and launches JRuby
# using appropriate flags and configuration. A few flags provide additional
# information:
#
# * `jruby --help` for standard options, most based on Ruby flags.
# * `jruby --properties` to list all JRuby JVM properties for finer-grained
# configuration.
# * `jruby --environment` to show the `java` command line that will be run and
# log output explaining how we got there.
#
# This script is intended to be compatible with POSIX shell as much as possible
# modulo a few small features known to be nonstandard but present in nearly all
# POSIX shell implementations. We tell shellcheck to treat this source as dash,
# a version of ash that adds those features and which has been the standard
# Debian /bin/sh since 2011.
#
# See https://en.wikipedia.org/wiki/Almquist_shell#Adoption_in_Debian_and_Ubuntu
#
# There are a number of utility functions defined here to cope with the lack of
# arrays in shell. These functions simulate arrays through other mechanism and
# ensure we do not damage quoting during argument processing.
# -----------------------------------------------------------------------------

# Enable uninitialized variable warnings
set -u

# ----- Guarantee local variables are available -------------------------------
if command -v local >/dev/null; then
:
Expand Down Expand Up @@ -138,7 +165,6 @@ esac
readonly cygwin

use_exec=true
java_opts_from_files=""
jdb=false

NO_BOOTCLASSPATH=false
Expand All @@ -157,6 +183,10 @@ fi

java_args=""
ruby_args=""

# shellcheck disable=2034 # variable is only read in an eval
java_opts_from_files=""
# shellcheck disable=2034 # variable is only read in an eval
jdb_args=""

# Force OpenJDK-based JVMs to use /dev/urandom for random number generation
Expand Down Expand Up @@ -507,10 +537,10 @@ else
case "${j#"$JRUBY_HOME/lib/"}" in
jruby.jar|jruby-complete.jar) continue
esac
if [ "$CP" ]; then
CP="$CP$CP_DELIMITER$j"
else
if [ -z "${CP-}" ]; then
CP="$j"
else
CP="$CP$CP_DELIMITER$2"
fi
done

Expand Down