From 9831b6f2ac9b9c780ecd805ab121014f0480e62b Mon Sep 17 00:00:00 2001 From: Oscar Wallberg Date: Wed, 23 Oct 2024 14:01:01 +0200 Subject: [PATCH] fix(setup): make copy item work with FORCE and IGNORE_EXISTING --- setup.sh | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/setup.sh b/setup.sh index abd222e..819198d 100755 --- a/setup.sh +++ b/setup.sh @@ -164,6 +164,14 @@ create_symlink() { ln -s "$src" "$dst" } +remove_path() { + local target + target="$1" + + echo "Trashing item: $target" + gio trash "$target" +} + copy_item() { local src dst dst_parent @@ -195,9 +203,15 @@ copy_item() { fi if test -e "$dst"; then - error "path already exists:" - error "${dst}" - return + if $FORCE; then + remove_path "$dst" + elif $IGNORE_EXISTING; then + return 0 + else + error "path already exists:" + error "${dst}" + return 1 + fi fi echo "Copying item: from $src to ${dst_parent}/"