Skip to content

Commit e9d69fa

Browse files
authored
Merge pull request jruby#8442 from mrnoname1000/launcher-option-file-esc
jruby.sh: Use array to handle option files
2 parents 80aa8fc + ac9fb59 commit e9d69fa

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

bin/jruby.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -174,24 +174,24 @@ add_log() {
174174

175175
# Logic to process "arguments files" on both Java 8 and Java 9+
176176
process_java_opts() {
177-
local java_opts_file="$1" java_opts=
177+
local java_opts_file="$1"
178178
if [ -r "$java_opts_file" ]; then
179179
add_log
180180
add_log "Adding Java options from: $java_opts_file"
181181

182-
while read -r line; do
183-
if [ "$line" ]; then
184-
java_opts="${java_opts} ${line}"
185-
add_log " $line"
186-
fi
187-
done < "$java_opts_file"
188-
189182
# On Java 9+, add an @argument for the given file.
190183
# On earlier versions the file contents will be read and expanded on the Java command line.
191184
if $use_modules; then
192-
java_opts_from_files="$java_opts_from_files @$java_opts_file"
185+
append java_opts_from_files "@$java_opts_file"
193186
else
194-
java_opts_from_files="$java_opts_from_files $java_opts"
187+
local line=
188+
while read -r line; do
189+
if [ "$line" ]; then
190+
# shellcheck disable=2086 # Split options on whitespace
191+
append java_opts_from_files $line
192+
add_log " $line"
193+
fi
194+
done < "$java_opts_file"
195195
fi
196196
fi
197197
}
@@ -685,12 +685,14 @@ fi
685685

686686
# ----- Final prepration of the Java command line -----------------------------
687687

688-
# Include all options from files at the beginning of the Java command line
689-
JAVA_OPTS="$java_opts_from_files $JAVA_OPTS"
690-
691688
# Don't quote JAVA_OPTS; we want it to expand
692689
# shellcheck disable=2086
693-
prepend java_args "$JAVACMD" $JAVA_OPTS "$JFFI_OPTS"
690+
prepend java_args $JAVA_OPTS "$JFFI_OPTS"
691+
692+
# Include all options from files at the beginning of the Java command line
693+
preextend java_args java_opts_from_files
694+
695+
prepend java_args "$JAVACMD"
694696

695697
if $NO_BOOTCLASSPATH || $VERIFY_JRUBY; then
696698
if $use_modules; then

0 commit comments

Comments
 (0)