Skip to content

Commit 3a17d27

Browse files
committed
Use shell glob instead of find command
1 parent c22d546 commit 3a17d27

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

‎cpp/build-support/fuzzing/generate_corpuses.sh‎

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,27 @@ OUT=$1
4141

4242
rm -rf "${CORPUS_DIR}"
4343
"${OUT}/arrow-ipc-generate-fuzz-corpus" -stream "${CORPUS_DIR}"
44+
45+
IPC_INTEGRATION_DIR="${ARROW_ROOT}/testing/data/arrow-ipc-stream/integration"
46+
4447
# Add "golden" IPC integration files
45-
# Store the files found by the find command in an array.
46-
mapfile -d '' IPC_INTEGRATION_FILES < <(
47-
find "${ARROW_ROOT}/testing/data/arrow-ipc-stream/integration" \
48-
-name "*.stream" -print0
49-
)
50-
# Exit with an error if find returns no files.
51-
[ "${#IPC_INTEGRATION_FILES[@]}" -eq 0 ] && exit 1
5248
# Several IPC integration files can have the same name, make sure
5349
# they all appear in the corpus by numbering the duplicates.
54-
cp --backup=numbered "${IPC_INTEGRATION_FILES[@]}" "${CORPUS_DIR}"
50+
# Use shell globbing to keep this ShellCheck-safe and compatible with Bash 3.2 on macOS.
51+
# IPC integration files are expected to be directly under each subdirectory.
52+
cp --backup=numbered \
53+
"${IPC_INTEGRATION_DIR}"/*/*.stream \
54+
"${CORPUS_DIR}"
55+
5556
"${ARROW_CPP}/build-support/fuzzing/pack_corpus.py" "${CORPUS_DIR}" "${OUT}/arrow-ipc-stream-fuzz_seed_corpus.zip"
5657

5758
rm -rf "${CORPUS_DIR}"
5859
"${OUT}/arrow-ipc-generate-fuzz-corpus" -file "${CORPUS_DIR}"
59-
# Store the files found by the find command in an array.
60-
mapfile -d '' IPC_INTEGRATION_FILES < <(
61-
find "${ARROW_ROOT}/testing/data/arrow-ipc-stream/integration" \
62-
-name "*.arrow_file" -print0
63-
)
64-
# Exit with an error if find returns no files.
65-
[ "${#IPC_INTEGRATION_FILES[@]}" -eq 0 ] && exit 1
66-
cp --backup=numbered "${IPC_INTEGRATION_FILES[@]}" "${CORPUS_DIR}"
60+
61+
cp --backup=numbered \
62+
"${IPC_INTEGRATION_DIR}"/*/*.arrow_file \
63+
"${CORPUS_DIR}"
64+
6765
"${ARROW_CPP}/build-support/fuzzing/pack_corpus.py" "${CORPUS_DIR}" "${OUT}/arrow-ipc-file-fuzz_seed_corpus.zip"
6866

6967
rm -rf "${CORPUS_DIR}"

0 commit comments

Comments
 (0)