Skip to content

Commit 9ad761f

Browse files
committedMar 19, 2018
Test expr behavior before using --. Fixes #5091
In #5013 we modified our bash script to use -- when calling the `expr` command, but this form is not supported on Alpine Linux's version of expr. This patch tests the behavior of `expr --` to determine which form to use.
1 parent 1bf6086 commit 9ad761f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

Diff for: ‎bin/jruby.bash

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ case "`uname`" in
2020
MINGW*) jruby.exe "$@"; exit $?;;
2121
esac
2222

23+
# ----- Determine how to call expr (jruby/jruby#5091) -------------------------
24+
# On Alpine linux, expr takes no -- arguments, and 'expr --' echoes '--'.
25+
_expr_dashed=$(expr -- 2>/dev/null)
26+
if [ "$_expr_dashed" != '--' ] ; then
27+
alias expr="expr --"
28+
fi
29+
unset _expr_dashed
30+
2331
# ----- Verify and Set Required Environment Variables -------------------------
2432
if [ -z "$JAVA_VM" ]; then
2533
JAVA_VM=-client
@@ -244,7 +252,7 @@ do
244252
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
245253
-X*)
246254
val=${1:2}
247-
if expr -- "$val" : '.*[.]' > /dev/null; then
255+
if expr "$val" : '.*[.]' > /dev/null; then
248256
java_args=("${java_args[@]}" "-Djruby.${val}")
249257
else
250258
ruby_args=("${ruby_args[@]}" "-X${val}")

0 commit comments

Comments
 (0)
Please sign in to comment.