Skip to content

Commit 25ede69

Browse files
committed
refactor: improve error handling in copy_directories function
Update the copy_directories function in lib/copy.sh to enhance error handling by using a conditional statement for the removal of matched paths. This change ensures that the removal status is only set when the command succeeds, improving code clarity and maintainability.
1 parent 5368d32 commit 25ede69

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/copy.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ copy_directories() {
290290
for matched_path in $pattern_suffix; do
291291
# Check if glob matched anything (avoid literal pattern if no match)
292292
if [ -e "$matched_path" ]; then
293-
rm -rf "$matched_path" 2>/dev/null && removed_any=1 || true
293+
if rm -rf "$matched_path" 2>/dev/null; then
294+
removed_any=1
295+
fi
294296
fi
295297
done
296298

0 commit comments

Comments
 (0)