This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new d0f318d1da GH-51485: [C++] Fix SC2086 errors in 
cpp/examples/tutorial_examples directory (#51486)
d0f318d1da is described below

commit d0f318d1da0a26e9e0c496279f2582895dad7988
Author: Hiroyuki Sato <[email protected]>
AuthorDate: Tue Sep 29 06:37:22 2026 +0900

    GH-51485: [C++] Fix SC2086 errors in cpp/examples/tutorial_examples 
directory (#51486)
    
    ### Rationale for this change
    
    This is the sub issue #44748.
    
    ```
    In build_arrow.sh line 23:
    mkdir -p $ARROW_BUILD_DIR
             ^--------------^ SC2086 (info): Double quote to prevent globbing 
and word splitting.
    
    Did you mean:
    mkdir -p "$ARROW_BUILD_DIR"
    
    In build_arrow.sh line 24:
    pushd $ARROW_BUILD_DIR
          ^--------------^ SC2086 (info): Double quote to prevent globbing and 
word splitting.
    
    Did you mean:
    pushd "$ARROW_BUILD_DIR"
    
    In build_arrow.sh line 33:
        $ARROW_CMAKE_OPTIONS
        ^------------------^ SC2086 (info): Double quote to prevent globbing 
and word splitting.
    
    Did you mean:
        "$ARROW_CMAKE_OPTIONS"
    
    In build_arrow.sh line 35:
    make -j$NPROC
           ^----^ SC2086 (info): Double quote to prevent globbing and word 
splitting.
    
    Did you mean:
    make -j"$NPROC"
    
    In build_example.sh line 21:
    mkdir -p $EXAMPLE_BUILD_DIR
             ^----------------^ SC2086 (info): Double quote to prevent globbing 
and word splitting.
    
    Did you mean:
    mkdir -p "$EXAMPLE_BUILD_DIR"
    
    In build_example.sh line 22:
    pushd $EXAMPLE_BUILD_DIR
          ^----------------^ SC2086 (info): Double quote to prevent globbing 
and word splitting.
    
    Did you mean:
    pushd "$EXAMPLE_BUILD_DIR"
    
    In build_example.sh line 24:
    cmake /io $EXAMPLE_CMAKE_OPTIONS
              ^--------------------^ SC2086 (info): Double quote to prevent 
globbing and word splitting.
    
    Did you mean:
    cmake /io "$EXAMPLE_CMAKE_OPTIONS"
    
    For more information:
      https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent 
globbing ...
    ```
    
    ### What changes are included in this PR?
    
    * SC2086: Quote variables
    
    ### Are these changes tested?
    
    Yes.
    
    ### Are there any user-facing changes?
    
    No.
    
    ### Was AI used for this PR?
    
    **PR code and description written by:**
    
    - [x] Human
    - [ ] AI
    
    **Reviewed before submission by:**
    
    - [x] Human
    - [ ] AI
    - [ ] Not reviewed
    
    * GitHub Issue: #51485
    
    Authored-by: Hiroyuki Sato <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 .pre-commit-config.yaml                         |  2 +-
 cpp/examples/tutorial_examples/build_arrow.sh   | 12 ++++++++----
 cpp/examples/tutorial_examples/build_example.sh | 10 +++++++---
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f370ff055b..789e06716e 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 4c08abdaae..e6486daee5 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 0b279890a7..1a671759de 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

Reply via email to