Skip to content

Commit 4cee12a

Browse files
committed
fix(launcher): trim trailing carriage returns on Windows within Java release metadata
Windows Temurin builds (for example) use CRLF in their `release` file; which breaks unquoting and thus the rest of the script. Signed-off-by: Chad Wilson <[email protected]>
1 parent e10eda1 commit 4cee12a

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

bin/jruby.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -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
@@ -1010,7 +1012,7 @@ add_log " $*"
10101012

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

0 commit comments

Comments
 (0)