From d160ccee1722adf647eff87351df8e7f276da6c9 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 02:52:25 +0000 Subject: [PATCH 1/2] refactor(test): replace eval with bash arrays in unit function Use read -ra to parse BUILD_FLAGS and TEST_FLAGS into arrays, so empty variables expand to zero arguments without needing eval. This avoids potential issues with shell metacharacter expansion. https://claude.ai/code/session_01L1fN5BiN9pbngSFbtEPRWL --- test.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test.sh b/test.sh index 6c027b36..5a487130 100755 --- a/test.sh +++ b/test.sh @@ -54,10 +54,12 @@ run_if() ( ) unit() ( - eval run_if "${LINT:-true}" cargo clippy "$@" -- -D warnings - eval run_if "${DOC:-false}" cargo doc "$@" - eval run_if "${BUILD:-true}" cargo build "${BUILD_FLAGS:-}" "$@" - eval run_if "${TEST:-true}" cargo test "${TEST_FLAGS:-}" "$@" + read -ra build_flags <<<"${BUILD_FLAGS:-}" + read -ra test_flags <<<"${TEST_FLAGS:-}" + run_if "${LINT:-true}" cargo clippy "$@" -- -D warnings + run_if "${DOC:-false}" cargo doc "$@" + run_if "${BUILD:-true}" cargo build "${build_flags[@]}" "$@" + run_if "${TEST:-true}" cargo test "${test_flags[@]}" "$@" ) run_if "${FMT:-true}" cargo fmt -- --check From 37d87052267054f70382cbd2f7f215f7051cd24a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 24 Mar 2026 03:04:13 +0000 Subject: [PATCH 2/2] fix(test): handle empty arrays under nounset on older bash Use ${arr[@]+"${arr[@]}"} pattern to safely expand potentially empty arrays. Bash 3.2 (macOS default) treats empty array expansion as an unbound variable error under set -o nounset. https://claude.ai/code/session_01L1fN5BiN9pbngSFbtEPRWL --- test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test.sh b/test.sh index 5a487130..3846d798 100755 --- a/test.sh +++ b/test.sh @@ -58,8 +58,8 @@ unit() ( read -ra test_flags <<<"${TEST_FLAGS:-}" run_if "${LINT:-true}" cargo clippy "$@" -- -D warnings run_if "${DOC:-false}" cargo doc "$@" - run_if "${BUILD:-true}" cargo build "${build_flags[@]}" "$@" - run_if "${TEST:-true}" cargo test "${test_flags[@]}" "$@" + run_if "${BUILD:-true}" cargo build ${build_flags[@]+"${build_flags[@]}"} "$@" + run_if "${TEST:-true}" cargo test ${test_flags[@]+"${test_flags[@]}"} "$@" ) run_if "${FMT:-true}" cargo fmt -- --check