diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f370ff055b18..789e06716e58 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -286,7 +286,7 @@ repos: ?^ci/.*\.sh$| ?^cpp/build-support/.*\.sh$| ?^cpp/examples/minimal_build/run\.sh$| - ?^cpp/examples/tutorial_examples/run\.sh$| + ?^cpp/examples/tutorial_examples/.*\.sh$| ?^cpp/src/.*\.sh$| ?^cpp/thirdparty/download_dependencies\.sh$| ?^dev/release/05-binary-upload\.sh$| diff --git a/cpp/examples/tutorial_examples/build_arrow.sh b/cpp/examples/tutorial_examples/build_arrow.sh index 4c08abdaae69..e6486daee5fd 100755 --- a/cpp/examples/tutorial_examples/build_arrow.sh +++ b/cpp/examples/tutorial_examples/build_arrow.sh @@ -20,8 +20,12 @@ set -ex NPROC=$(nproc) -mkdir -p $ARROW_BUILD_DIR -pushd $ARROW_BUILD_DIR +mkdir -p "$ARROW_BUILD_DIR" +pushd "$ARROW_BUILD_DIR" + +# Convert the space-separated CMake options into a Bash array. +# This avoids ShellCheck SC2086 and preserves argument boundaries. +read -r -a ARROW_CMAKE_OPTIONS_ARRAY <<< "$ARROW_CMAKE_OPTIONS" # Enable the CSV reader as it's used by the example third-party build cmake /arrow/cpp \ @@ -30,9 +34,9 @@ cmake /arrow/cpp \ -DARROW_FILESYSTEM=ON \ -DARROW_PARQUET=ON \ -DARROW_MIMALLOC=OFF \ - $ARROW_CMAKE_OPTIONS + "${ARROW_CMAKE_OPTIONS_ARRAY[@]}" -make -j$NPROC +make -j"$NPROC" make install popd diff --git a/cpp/examples/tutorial_examples/build_example.sh b/cpp/examples/tutorial_examples/build_example.sh index 0b279890a78e..1a671759de13 100755 --- a/cpp/examples/tutorial_examples/build_example.sh +++ b/cpp/examples/tutorial_examples/build_example.sh @@ -18,10 +18,14 @@ set -ex -mkdir -p $EXAMPLE_BUILD_DIR -pushd $EXAMPLE_BUILD_DIR +mkdir -p "$EXAMPLE_BUILD_DIR" +pushd "$EXAMPLE_BUILD_DIR" -cmake /io $EXAMPLE_CMAKE_OPTIONS +# Convert the space-separated CMake options into a Bash array. +# This avoids ShellCheck SC2086 and preserves argument boundaries. +read -r -a EXAMPLE_CMAKE_OPTIONS_ARRAY <<< "$EXAMPLE_CMAKE_OPTIONS" + +cmake /io "${EXAMPLE_CMAKE_OPTIONS_ARRAY[@]}" make popd