Skip to content

Commit d7ecd41

Browse files
committed
fix: add recursive fallback and set -e guards for find in copy_directories
- Add || true to all find invocations to prevent silent exits under set -e - Fall back to recursive find when shallow (-maxdepth 1) search finds nothing, preserving backward compatibility for nested directory patterns
1 parent 86901f3 commit d7ecd41

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

lib/copy.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,14 @@ copy_directories() {
332332
# Use -path for patterns with slashes (e.g., vendor/bundle), -name for basenames
333333
# Note: case inside $() inside heredocs breaks Bash 3.2, so compute first
334334
# Use -maxdepth 1 for simple basenames to avoid scanning entire repo (e.g., node_modules)
335+
# Falls back to recursive search if shallow search finds nothing
335336
local find_results
336337
case "$pattern" in
337-
*/*) find_results=$(find . -type d -path "./$pattern" 2>/dev/null) ;;
338-
*) find_results=$(find . -maxdepth 1 -type d -name "$pattern" 2>/dev/null) ;;
338+
*/*) find_results=$(find . -type d -path "./$pattern" 2>/dev/null || true) ;;
339+
*) find_results=$(find . -maxdepth 1 -type d -name "$pattern" 2>/dev/null || true)
340+
if [ -z "$find_results" ]; then
341+
find_results=$(find . -type d -name "$pattern" 2>/dev/null || true)
342+
fi ;;
339343
esac
340344

341345
while IFS= read -r dir_path; do

0 commit comments

Comments
 (0)