diff --git a/bin/ruby-build b/bin/ruby-build index 43376d4d..d590f111 100755 --- a/bin/ruby-build +++ b/bin/ruby-build @@ -969,11 +969,16 @@ build_package_verify_openssl() { # Ensure that directories listed in LDFLAGS exist build_package_ldflags_dirs() { - local arg - for arg in $LDFLAGS; do - case "$arg" in - -L* ) mkdir -p "${arg#-L}" ;; + local arg dir + set - $LDFLAGS + while [ $# -gt 0 ]; do + dir="" + case "$1" in + -L ) dir="$2" ;; + -L* ) dir="${1#-L}" ;; esac + [ -z "$dir" ] || mkdir -p "$dir" + shift 1 done } diff --git a/test/build.bats b/test/build.bats index 76425a71..a3c65e84 100644 --- a/test/build.bats +++ b/test/build.bats @@ -630,3 +630,16 @@ DEF run ruby-build "${TMP}/build-definition" "$INSTALL_ROOT" assert_failure "ruby-build: TMPDIR=$TMPDIR is set to a non-accessible location" } + +@test "initializes LDFLAGS directories" { + cached_tarball "ruby-2.0.0" + + export LDFLAGS="-L ${BATS_TEST_DIRNAME}/what/evs" + run_inline_definition <