From 403884e1d8828785343d6a2c3c2477481702ce1e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 6 Jul 2020 17:38:11 +0200 Subject: [PATCH] Fix quoting of CXXFLAGS passed to make Use arrays to simplify passing CXXFLAGS and LDFLAGS, both of them may contain spaces, separately on make command line. Simpler solution of just using individual variable doesn't work because of bash/POSIX word splitting behaviour (zsh should be blamed for spoiling me with its much more reasonable behaviour and allowing me to forget about this insanity in the first place). In principle, we could work around this by temporarily resetting IFS, but using arrays is arguably more clear and this script already uses bashisms, in spite of its shebang line. --- build/tools/travis-ci.sh | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/build/tools/travis-ci.sh b/build/tools/travis-ci.sh index b804e53bef..37eb8b94f6 100755 --- a/build/tools/travis-ci.sh +++ b/build/tools/travis-ci.sh @@ -84,25 +84,28 @@ case $wxTOOLSET in error_opts="-Werror $allow_warn_opt" wxMAKEFILE_CXXFLAGS="$wxMAKEFILE_CXXFLAGS $error_opts" - wxMAKEFILE_ERROR_CXXFLAGS="CXXFLAGS=$error_opts" + wxMAKEFILE_ERROR_CXXFLAGS=("CXXFLAGS=$error_opts") + else + wxMAKEFILE_ERROR_CXXFLAGS=() fi + wxMAKEFILE_FLAGS=() if [ -n "$wxMAKEFILE_CXXFLAGS" ]; then - wxMAKEFILE_FLAGS="CXXFLAGS=$wxMAKEFILE_CXXFLAGS" + wxMAKEFILE_FLAGS+=("CXXFLAGS=$wxMAKEFILE_CXXFLAGS") fi if [ -n "$wxMAKEFILE_LDFLAGS" ]; then - wxMAKEFILE_FLAGS="$wxMAKEFILE_FLAGS LDFLAGS=$wxMAKEFILE_LDFLAGS" + wxMAKEFILE_FLAGS+=("LDFLAGS=$wxMAKEFILE_LDFLAGS") fi echo 'travis_fold:start:building' echo 'Building...' - make -k $wxBUILD_ARGS $wxMAKEFILE_ERROR_CXXFLAGS + make -k $wxBUILD_ARGS "${wxMAKEFILE_ERROR_CXXFLAGS[@]}" echo 'travis_fold:end:building' echo 'travis_fold:start:tests' echo 'Building tests...' [ "$wxSKIP_GUI" = 1 ] || make -C tests $wxBUILD_ARGS failtest - make -k -C tests $wxBUILD_ARGS $wxMAKEFILE_FLAGS + make -k -C tests $wxBUILD_ARGS "${wxMAKEFILE_FLAGS[@]}" echo 'travis_fold:end:tests' if [ "$wxSKIP_TESTING" = 1 ]; then @@ -129,7 +132,7 @@ case $wxTOOLSET in echo 'travis_fold:start:samples' echo 'Building samples...' - (test "$wxSKIP_SAMPLES" && echo 'SKIPPED') || make -k $wxMAKEFILE_FLAGS samples + (test "$wxSKIP_SAMPLES" && echo 'SKIPPED') || make -k "${wxMAKEFILE_FLAGS[@]}" samples echo 'travis_fold:end:samples' echo 'travis_fold:start:install' @@ -140,7 +143,7 @@ case $wxTOOLSET in echo 'travis_fold:start:testinstall' echo 'Testing installation...' make -C samples/minimal -f makefile.unx clean - make -C samples/minimal -f makefile.unx $wxMAKEFILE_FLAGS + make -C samples/minimal -f makefile.unx "${wxMAKEFILE_FLAGS[@]}" echo 'travis_fold:end:testinstall' ;; esac