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 e85e181188a GH-51670: [C++][Dev] Fix shellcheck errors in the
cpp/examples/minimal_build directory (#51671)
e85e181188a is described below
commit e85e181188ac3c5e8407b2160331faf5e78fd429
Author: Hiroyuki Sato <[email protected]>
AuthorDate: Sat Oct 3 06:18:44 2026 +0900
GH-51670: [C++][Dev] Fix shellcheck errors in the
cpp/examples/minimal_build directory (#51671)
### Rationale for this change
This is the sub issue #44748.
* SC2046: Quote this to prevent word splitting
* SC2086: Double quote to prevent globbing and word splitting
* SC2223: This default assignment may cause DoS due to globbing. Quote it
```
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 30:
$ARROW_CMAKE_OPTIONS
^------------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
"$ARROW_CMAKE_OPTIONS"
In build_arrow.sh line 32:
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 run_static.sh line 21:
: ${ARROW_DIR:=/arrow}
^------------------^ SC2223 (info): This default assignment may cause DoS
due to globbing. Quote it.
In run_static.sh line 22:
: ${EXAMPLE_DIR:=/io}
^-----------------^ SC2223 (info): This default assignment may cause DoS
due to globbing. Quote it.
In run_static.sh line 23:
: ${ARROW_BUILD_DIR:=/build/arrow}
^-- SC2223 (info): This default assignment may cause DoS due to globbing.
Quote it.
In run_static.sh line 24:
: ${EXAMPLE_BUILD_DIR:=/build/example}
^-- SC2223 (info): This default assignment may cause DoS due to globbing.
Quote it.
In run_static.sh line 26:
: ${ARROW_DEPENDENCY_SOURCE:=BUNDLED}
^-- SC2223 (info): This default assignment may cause DoS due to globbing.
Quote it.
In run_static.sh line 34:
mkdir -p $ARROW_BUILD_DIR
^--------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
mkdir -p "$ARROW_BUILD_DIR"
In run_static.sh line 35:
pushd $ARROW_BUILD_DIR
^--------------^ SC2086 (info): Double quote to prevent globbing and
word splitting.
Did you mean:
pushd "$ARROW_BUILD_DIR"
In run_static.sh line 39:
cmake $ARROW_DIR/cpp \
^--------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
cmake "$ARROW_DIR"/cpp \
In run_static.sh line 43:
-DARROW_DEPENDENCY_SOURCE=${ARROW_DEPENDENCY_SOURCE} \
^------------------------^ SC2086 (info):
Double quote to prevent globbing and word splitting.
Did you mean:
-DARROW_DEPENDENCY_SOURCE="${ARROW_DEPENDENCY_SOURCE}" \
In run_static.sh line 46:
$ARROW_CMAKE_OPTIONS
^------------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
"$ARROW_CMAKE_OPTIONS"
In run_static.sh line 48:
make -j$NPROC
^----^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
make -j"$NPROC"
In run_static.sh line 60:
rm -rf $EXAMPLE_BUILD_DIR
^----------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
rm -rf "$EXAMPLE_BUILD_DIR"
In run_static.sh line 61:
mkdir -p $EXAMPLE_BUILD_DIR
^----------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
mkdir -p "$EXAMPLE_BUILD_DIR"
In run_static.sh line 62:
pushd $EXAMPLE_BUILD_DIR
^----------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
pushd "$EXAMPLE_BUILD_DIR"
In run_static.sh line 64:
cmake $EXAMPLE_DIR -DARROW_LINK_SHARED=OFF
^----------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
cmake "$EXAMPLE_DIR" -DARROW_LINK_SHARED=OFF
In run_static.sh line 76:
pushd $EXAMPLE_DIR
^----------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
pushd "$EXAMPLE_DIR"
In run_static.sh line 78:
$EXAMPLE_BUILD_DIR/arrow-example
^----------------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
"$EXAMPLE_BUILD_DIR"/arrow-example
In run_static.sh line 87:
rm -rf $EXAMPLE_BUILD_DIR
^----------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
rm -rf "$EXAMPLE_BUILD_DIR"
In run_static.sh line 88:
mkdir -p $EXAMPLE_BUILD_DIR
^----------------^ SC2086 (info): Double quote to prevent globbing
and word splitting.
Did you mean:
mkdir -p "$EXAMPLE_BUILD_DIR"
In run_static.sh line 90:
-o $EXAMPLE_BUILD_DIR/arrow-example \
^----------------^ SC2086 (info): Double quote to prevent globbing and
word splitting.
Did you mean:
-o "$EXAMPLE_BUILD_DIR"/arrow-example \
In run_static.sh line 91:
$EXAMPLE_DIR/example.cc \
^----------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
"$EXAMPLE_DIR"/example.cc \
In run_static.sh line 92:
$(PKG_CONFIG_PATH=$ARROW_BUILD_DIR/lib/pkgconfig \
^-- SC2046 (warning): Quote this to prevent word splitting.
In run_static.sh line 104:
pushd $EXAMPLE_DIR
^----------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
pushd "$EXAMPLE_DIR"
In run_static.sh line 106:
$EXAMPLE_BUILD_DIR/arrow-example
^----------------^ SC2086 (info): Double quote to prevent globbing and word
splitting.
Did you mean:
"$EXAMPLE_BUILD_DIR"/arrow-example
For more information:
https://www.shellcheck.net/wiki/SC2046 -- Quote this to prevent word
splitt...
https://www.shellcheck.net/wiki/SC2086 -- Double quote to prevent
globbing ...
https://www.shellcheck.net/wiki/SC2223 -- This default assignment may
cause...
```
### What changes are included in this PR?
* SC2046: Quote command substitutions
* SC2086: Quote variables
* SC2223: Quote default assignments
### Are these changes tested?
Yes.
### Are there any user-facing changes?
No.
### Was AI used for this PR?
In accordance to the [AI generation
guidelines](https://arrow.apache.org/docs/dev/developers/overview.html#ai-generated-code),
please disclose below whether and how AI was used in this PR.
**PR code and description written by:**
- [x] Human
- [ ] AI
**Reviewed before submission by:**
- [x] Human
- [ ] AI
- [ ] Not reviewed
* GitHub Issue: #51670
Authored-by: Hiroyuki Sato <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
---
.pre-commit-config.yaml | 6 +--
cpp/examples/minimal_build/build_arrow.sh | 12 ++++--
cpp/examples/minimal_build/build_example.sh | 4 +-
cpp/examples/minimal_build/run_static.sh | 58 ++++++++++++++++-------------
4 files changed, 44 insertions(+), 36 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 789e06716e5..50293d291f4 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -284,11 +284,7 @@ repos:
(
?^c_glib/.*\.sh$|
?^ci/.*\.sh$|
- ?^cpp/build-support/.*\.sh$|
- ?^cpp/examples/minimal_build/run\.sh$|
- ?^cpp/examples/tutorial_examples/.*\.sh$|
- ?^cpp/src/.*\.sh$|
- ?^cpp/thirdparty/download_dependencies\.sh$|
+ ?^cpp/.*\.sh$|
?^dev/release/05-binary-upload\.sh$|
?^dev/release/07-flightsqlodbc-upload\.sh$|
?^dev/release/08-publish-gh-release\.sh$|
diff --git a/cpp/examples/minimal_build/build_arrow.sh
b/cpp/examples/minimal_build/build_arrow.sh
index 7045439c1a6..be9a4eb51e1 100755
--- a/cpp/examples/minimal_build/build_arrow.sh
+++ b/cpp/examples/minimal_build/build_arrow.sh
@@ -20,16 +20,20 @@ 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 \
-DARROW_CSV=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/minimal_build/build_example.sh
b/cpp/examples/minimal_build/build_example.sh
index a315755a597..02fa95b7d41 100755
--- a/cpp/examples/minimal_build/build_example.sh
+++ b/cpp/examples/minimal_build/build_example.sh
@@ -18,8 +18,8 @@
set -ex
-mkdir -p $EXAMPLE_BUILD_DIR
-pushd $EXAMPLE_BUILD_DIR
+mkdir -p "$EXAMPLE_BUILD_DIR"
+pushd "$EXAMPLE_BUILD_DIR"
cmake /io
make
diff --git a/cpp/examples/minimal_build/run_static.sh
b/cpp/examples/minimal_build/run_static.sh
index 26019227a7b..55b1d9eb362 100755
--- a/cpp/examples/minimal_build/run_static.sh
+++ b/cpp/examples/minimal_build/run_static.sh
@@ -18,12 +18,12 @@
set -e
-: ${ARROW_DIR:=/arrow}
-: ${EXAMPLE_DIR:=/io}
-: ${ARROW_BUILD_DIR:=/build/arrow}
-: ${EXAMPLE_BUILD_DIR:=/build/example}
+: "${ARROW_DIR:=/arrow}"
+: "${EXAMPLE_DIR:=/io}"
+: "${ARROW_BUILD_DIR:=/build/arrow}"
+: "${EXAMPLE_BUILD_DIR:=/build/example}"
-: ${ARROW_DEPENDENCY_SOURCE:=BUNDLED}
+: "${ARROW_DEPENDENCY_SOURCE:=BUNDLED}"
echo
echo "=="
@@ -31,21 +31,25 @@ echo "== Building Arrow C++ library"
echo "=="
echo
-mkdir -p $ARROW_BUILD_DIR
-pushd $ARROW_BUILD_DIR
+mkdir -p "$ARROW_BUILD_DIR"
+pushd "$ARROW_BUILD_DIR"
NPROC=$(nproc)
-cmake $ARROW_DIR/cpp \
+# 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"
+
+cmake "$ARROW_DIR"/cpp \
-DARROW_BUILD_SHARED=OFF \
-DARROW_BUILD_STATIC=ON \
-DARROW_CSV=ON \
- -DARROW_DEPENDENCY_SOURCE=${ARROW_DEPENDENCY_SOURCE} \
+ -DARROW_DEPENDENCY_SOURCE="${ARROW_DEPENDENCY_SOURCE}" \
-DARROW_DEPENDENCY_USE_SHARED=OFF \
-Dxsimd_SOURCE=BUNDLED \
- $ARROW_CMAKE_OPTIONS
+ "${ARROW_CMAKE_OPTIONS_ARRAY[@]}"
-make -j$NPROC
+make -j"$NPROC"
make install
popd
@@ -57,11 +61,11 @@ echo "== Building example project using Arrow C++ library"
echo "=="
echo
-rm -rf $EXAMPLE_BUILD_DIR
-mkdir -p $EXAMPLE_BUILD_DIR
-pushd $EXAMPLE_BUILD_DIR
+rm -rf "$EXAMPLE_BUILD_DIR"
+mkdir -p "$EXAMPLE_BUILD_DIR"
+pushd "$EXAMPLE_BUILD_DIR"
-cmake $EXAMPLE_DIR -DARROW_LINK_SHARED=OFF
+cmake "$EXAMPLE_DIR" -DARROW_LINK_SHARED=OFF
make
popd
@@ -73,9 +77,9 @@ echo "== Running example project"
echo "=="
echo
-pushd $EXAMPLE_DIR
+pushd "$EXAMPLE_DIR"
-$EXAMPLE_BUILD_DIR/arrow-example
+"${EXAMPLE_BUILD_DIR}/arrow-example"
echo
echo "=="
@@ -84,13 +88,17 @@ echo "== Building example project using Arrow C++ library"
echo "=="
echo
-rm -rf $EXAMPLE_BUILD_DIR
-mkdir -p $EXAMPLE_BUILD_DIR
+read -ra ARROW_BUILD_FLAGS <<< "$(
+ PKG_CONFIG_PATH="$ARROW_BUILD_DIR/lib/pkgconfig" \
+ pkg-config --cflags --libs --static arrow
+)"
+
+rm -rf "$EXAMPLE_BUILD_DIR"
+mkdir -p "$EXAMPLE_BUILD_DIR"
${CXX:-c++} -std=c++20 \
- -o $EXAMPLE_BUILD_DIR/arrow-example \
- $EXAMPLE_DIR/example.cc \
- $(PKG_CONFIG_PATH=$ARROW_BUILD_DIR/lib/pkgconfig \
- pkg-config --cflags --libs --static arrow)
+ -o "${EXAMPLE_BUILD_DIR}/arrow-example" \
+ "${EXAMPLE_DIR}/example.cc" \
+ "${ARROW_BUILD_FLAGS[@]}"
popd
@@ -101,6 +109,6 @@ echo "== Running example project"
echo "=="
echo
-pushd $EXAMPLE_DIR
+pushd "$EXAMPLE_DIR"
-$EXAMPLE_BUILD_DIR/arrow-example
+"${EXAMPLE_BUILD_DIR}/arrow-example"