Backport #8071
closedRuby 2.0 ./configure fails with syntax error on Illumos distributions
Description
Trying to build Ruby 2.0 on Illumos distributions, ./configure fails with the following syntax error:
./configure: line 2780: syntax error at line 19075: `(' unexpected
The problem code is in this function:
shvar_to_cpp() {
local var="$1" val="$2"
local exec_prefix_pat="echo \"${exec_prefix}\" | sed 's/\\./\\\\./g'
"
local arch_pat="echo \"${arch}\" | sed 's/\\./\\\\./g'
"
local sitearch_pat="echo \"${sitearch}\" | sed 's/\\./\\\\./g'
"
val="echo '"'"${val}"'"' | sed \ -e 's/\${\([A-Z][A-Z_]*\)}/"\1"/g' \ -e 's|\${sitearchlibdir}|'"${sitearchlibdir}|g" \ -e 's|\${sitearchincludedir}|'"${sitearchincludedir}|g" \ -e 's|\${archlibdir}|'"${archlibdir}|g" \ -e 's|\${archincludedir}|'"${archincludedir}|g" \ -e 's|\${libdir}|'"${libdir}|g" \ -e 's/\${ruby_version}/"RUBY_LIB_VERSION"/g' \ -e 's/\${arch}/"arch"/g' \ -e 's/\${sitearch}/"arch"/g' \ -e 's/\${vendorarchdir}/"RUBY_VENDOR_ARCH_LIB"/g' \ -e 's/\${sitearchdir}/"RUBY_SITE_ARCH_LIB"/g' \ -e 's/\${vendorlibdir}/"RUBY_VENDOR_LIB2"/g' \ -e 's/\${sitelibdir}/"RUBY_SITE_LIB2"/g' \ -e 's/\${vendordir}/"RUBY_VENDOR_LIB"/g' \ -e 's/\${sitedir}/"RUBY_SITE_LIB"/g' \ -e 's/\${rubylibdir}/"RUBY_LIB"/g' \ -e 's/\${rubylibprefix}/"RUBY_LIB_PREFIX"/g' \ -e 's/\${rubyarchprefix}/"RUBY_ARCH_PREFIX_FOR(arch)"/g' \ -e 's/\${rubysitearchprefix}/"RUBY_SITEARCH_PREFIX_FOR(arch)"/g' \ -e 's/\${exec_prefix}/"RUBY_EXEC_PREFIX"/g' \ -e "s|${exec_prefix_pat}/|"'"RUBY_EXEC_PREFIX"/|g' \ -e "s|${arch_pat}|"'"arch"|g' \ -e "s|${sitearch_pat}|"'"sitearch"|g' \ -e 's|^\"NONE/|RUBY_EXEC_PREFIX\"/|' \ -e 's|^\"NONE\"|\"'"${prefix}"'\"|' \ -e 's/^\"\"\(.\)/\1/;s/\(.\)\"\"$/\1/'
"
eval $var='"$val"'
}
Specifically these two lines:
-e 's/${rubyarchprefix}/"RUBY_ARCH_PREFIX_FOR(arch)"/g'
-e 's/${rubysitearchprefix}/"RUBY_SITEARCH_PREFIX_FOR(arch)"/g' \
I tested this on both SmartOS and OmniOS. On both of these distributions /bin/sh is ksh93.
I was able to work around this problem by using the GNU version of sh or bash instead of /bin/sh.