Skip to content

Commit e2bdf61

Browse files
authored
Merge pull request jruby#9128 from chadlwilson/launcher-windows-fixes-94
[9.4] fix(launcher): correct parsing of java release files under Bash/msys2 etc on Windows
2 parents 4766b0b + 39a9419 commit e2bdf61

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

bin/jruby.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/sh
2-
# shellcheck shell=dash # local variable support
3-
# shellcheck disable=1007 # spurious warnings when initializing multiple vars
2+
# shellcheck disable=3043 # assume local variable support in shell
43

54
# -----------------------------------------------------------------------------
65
# jruby.sh - Start Script for the JRuby interpreter
@@ -59,6 +58,7 @@ fi
5958
# https://github.com/mentalisttraceur/esceval
6059
esceval()
6160
{
61+
# shellcheck disable=1007 # multiple empty var initialization intentional here
6262
local escaped= unescaped= output=
6363
REPLY=
6464

@@ -244,12 +244,13 @@ if [ -r "/dev/urandom" ]; then
244244
JAVA_SECURITY_EGD="file:/dev/urandom"
245245
fi
246246

247-
# Gather environment information as we go
248-
readonly cr='
247+
cr="$(printf '\r')" && readonly cr
248+
readonly nl='
249249
'
250+
# Gather environment information as we go
250251
environment_log=""
251252
add_log() {
252-
environment_log="${environment_log}${cr}${*-}"
253+
environment_log="${environment_log}${nl}${*-}"
253254
}
254255

255256
# Logic to process "arguments files" on both Java 8 and Java 9+
@@ -265,7 +266,7 @@ process_java_opts() {
265266
append java_opts_from_files "@$java_opts_file"
266267
else
267268
local line=
268-
while read -r line; do
269+
while IFS="$cr" read -r line; do
269270
if [ "$line" ]; then
270271
# shellcheck disable=2086 # Split options on whitespace
271272
append java_opts_from_files $line
@@ -533,7 +534,7 @@ java_major=8
533534
# shellcheck source=/dev/null
534535
if [ -f "$JAVA_HOME/release" ]; then
535536
# Get java version from JAVA_HOME/release file
536-
while IFS= read -r line; do
537+
while IFS="$cr" read -r line; do
537538
case $line in
538539
(\#*) continue ;;
539540
esac
@@ -543,7 +544,7 @@ if [ -f "$JAVA_HOME/release" ]; then
543544

544545
case $name in
545546
(JAVA_VERSION) unquote "$value" && java_version=$REPLY ;;
546-
(JAVA_RELEASE_VERSION) unquote "$value" && java_runtime_version=$REPLY ;;
547+
(JAVA_RUNTIME_VERSION) unquote "$value" && java_runtime_version=$REPLY ;;
547548
esac
548549
done < "$JAVA_HOME"/release
549550
unset line name value
@@ -573,8 +574,9 @@ fi
573574
# Default java_runtime_version to $java_version
574575
: "${java_runtime_version:=$java_version}"
575576

576-
add_log "Detected Java version: $java_version"
577+
add_log "Detected Java version: $java_version (major: $java_major)"
577578
add_log "Detected Java runtime version: $java_runtime_version"
579+
add_log "Detected JRuby minimum java version: $minimum_java_version"
578580

579581
# Present a useful error if running a Java version lower than bin/.java-version
580582
if [ "$java_major" -lt "$minimum_java_version" ]; then
@@ -1009,7 +1011,7 @@ add_log " $*"
10091011

10101012
# shellcheck source=/dev/null
10111013
if $print_environment_log; then
1012-
environment_log="JRuby Environment${cr}=================${cr}${cr}JRuby version: ${jruby_version}${environment_log}"
1014+
environment_log="JRuby Environment${nl}=================${nl}${nl}JRuby version: ${jruby_version}${environment_log}"
10131015
echo "$environment_log"
10141016
exit 0
10151017
fi

0 commit comments

Comments
 (0)