Skip to content

Commit ba71d11

Browse files
KSXGitHubclaude
andauthored
fix(test): parse BUILD_FLAGS and TEST_FLAGS (#371)
* 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 * 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 --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9347295 commit ba71d11

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

test.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ run_if() (
5454
)
5555

5656
unit() (
57-
eval run_if "${LINT:-true}" cargo clippy "$@" -- -D warnings
58-
eval run_if "${DOC:-false}" cargo doc "$@"
59-
eval run_if "${BUILD:-true}" cargo build "${BUILD_FLAGS:-}" "$@"
60-
eval run_if "${TEST:-true}" cargo test "${TEST_FLAGS:-}" "$@"
57+
read -ra build_flags <<<"${BUILD_FLAGS:-}"
58+
read -ra test_flags <<<"${TEST_FLAGS:-}"
59+
run_if "${LINT:-true}" cargo clippy "$@" -- -D warnings
60+
run_if "${DOC:-false}" cargo doc "$@"
61+
run_if "${BUILD:-true}" cargo build ${build_flags[@]+"${build_flags[@]}"} "$@"
62+
run_if "${TEST:-true}" cargo test ${test_flags[@]+"${test_flags[@]}"} "$@"
6163
)
6264

6365
run_if "${FMT:-true}" cargo fmt -- --check

0 commit comments

Comments
 (0)