Skip to content

Commit d160cce

Browse files
committed
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
1 parent 9347295 commit d160cce

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[@]}" "$@"
62+
run_if "${TEST:-true}" cargo test "${test_flags[@]}" "$@"
6163
)
6264

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

0 commit comments

Comments
 (0)