Skip to content

Commit 479a50a

Browse files
authored
Merge pull request jruby#8656 from headius/more_sh_fixes
Additional fixes for jruby.sh
2 parents bc239fe + 71b6144 commit 479a50a

File tree

2 files changed

+49
-6
lines changed

2 files changed

+49
-6
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,19 @@ jobs:
409409
env:
410410
PHASE: 'package -Ptest'
411411

412+
jruby-shell-check:
413+
runs-on: ubuntu-latest
414+
415+
name: shellcheck jruby.sh
416+
417+
steps:
418+
- name: checkout
419+
uses: actions/checkout@v3
420+
- name: install shellcheck
421+
run: sudo apt install shellcheck
422+
- name: run shellcheck
423+
run: shellcheck bin/jruby.sh
424+
412425
rake-test-wip-8:
413426
runs-on: ubuntu-latest
414427

bin/jruby.sh

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
11
#!/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+
45
# -----------------------------------------------------------------------------
56
# 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.
630
# -----------------------------------------------------------------------------
731

32+
# Enable uninitialized variable warnings
33+
set -u
34+
835
# ----- Guarantee local variables are available -------------------------------
936
if command -v local >/dev/null; then
1037
:
@@ -138,7 +165,6 @@ esac
138165
readonly cygwin
139166

140167
use_exec=true
141-
java_opts_from_files=""
142168
jdb=false
143169

144170
NO_BOOTCLASSPATH=false
@@ -157,6 +183,10 @@ fi
157183

158184
java_args=""
159185
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
160190
jdb_args=""
161191

162192
# Force OpenJDK-based JVMs to use /dev/urandom for random number generation
@@ -507,10 +537,10 @@ else
507537
case "${j#"$JRUBY_HOME/lib/"}" in
508538
jruby.jar|jruby-complete.jar) continue
509539
esac
510-
if [ "$CP" ]; then
511-
CP="$CP$CP_DELIMITER$j"
512-
else
540+
if [ -z "${CP-}" ]; then
513541
CP="$j"
542+
else
543+
CP="$CP$CP_DELIMITER$2"
514544
fi
515545
done
516546

0 commit comments

Comments
 (0)