Skip to content

Commit a0ce2f5

Browse files
committed
fix: hoist case out of heredoc for Bash 3.2 compatibility
Bash 3.2 cannot parse case/esac inside $() inside heredocs, causing copy_directories() to silently fail on macOS system Bash. Move the find command into a variable before the heredoc.
1 parent 673193c commit a0ce2f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/copy.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,13 @@ copy_directories() {
329329

330330
# Find directories matching the pattern
331331
# Use -path for patterns with slashes (e.g., vendor/bundle), -name for basenames
332+
# Note: case inside $() inside heredocs breaks Bash 3.2, so compute first
333+
local find_results
334+
case "$pattern" in
335+
*/*) find_results=$(find . -type d -path "./$pattern" 2>/dev/null) ;;
336+
*) find_results=$(find . -type d -name "$pattern" 2>/dev/null) ;;
337+
esac
338+
332339
while IFS= read -r dir_path; do
333340
[ -z "$dir_path" ] && continue
334341
dir_path="${dir_path#./}"
@@ -350,7 +357,7 @@ copy_directories() {
350357
log_warn "Failed to copy directory $dir_path"
351358
fi
352359
done <<EOF
353-
$(case "$pattern" in */*) find . -type d -path "./$pattern" 2>/dev/null ;; *) find . -type d -name "$pattern" 2>/dev/null ;; esac)
360+
$find_results
354361
EOF
355362
done <<EOF
356363
$dir_patterns

0 commit comments

Comments
 (0)