Skip to content

Commit

Permalink
Test expr behavior before using --. Fixes #5091
Browse files Browse the repository at this point in the history
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.
headius committed Mar 19, 2018

Verified

This commit was signed with the committer’s verified signature.
headius Charles Oliver Nutter
1 parent 1bf6086 commit 9ad761f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bin/jruby.bash
Original file line number Diff line number Diff line change
@@ -20,6 +20,14 @@ case "`uname`" in
MINGW*) jruby.exe "$@"; exit $?;;
esac

# ----- Determine how to call expr (jruby/jruby#5091) -------------------------
# On Alpine linux, expr takes no -- arguments, and 'expr --' echoes '--'.
_expr_dashed=$(expr -- 2>/dev/null)
if [ "$_expr_dashed" != '--' ] ; then
alias expr="expr --"
fi
unset _expr_dashed

# ----- Verify and Set Required Environment Variables -------------------------
if [ -z "$JAVA_VM" ]; then
JAVA_VM=-client
@@ -244,7 +252,7 @@ do
# Match -Xa.b.c=d to translate to -Da.b.c=d as a java option
-X*)
val=${1:2}
if expr -- "$val" : '.*[.]' > /dev/null; then
if expr "$val" : '.*[.]' > /dev/null; then
java_args=("${java_args[@]}" "-Djruby.${val}")
else
ruby_args=("${ruby_args[@]}" "-X${val}")

0 comments on commit 9ad761f

Please sign in to comment.