aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/update.sh
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-11-11 04:21:16 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-11-11 04:21:16 +0300
commit3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef (patch)
tree9afc392cf1a566e8cce605c8ee35a463a3e43ada /update.sh
parentbugfix (diff)
downloadconfig-links-3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef.tar.gz
config-links-3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef.zip
don't delete obsolete files which are not symlinks
Diffstat (limited to 'update.sh')
-rwxr-xr-xupdate.sh18
1 files changed, 10 insertions, 8 deletions
diff --git a/update.sh b/update.sh
index a1467fc..ea2519f 100755
--- a/update.sh
+++ b/update.sh
@@ -287,18 +287,20 @@ delete_obsolete_entries() {
if [ ! -e "$shared_path" ]; then
dump " missing source file: $shared_path" >&2
- if [ -z "${dry_run+x}" ]; then
- rm -f -- "$symlink_path"
- else
+ if [ ! -L "$symlink_path" ]; then
+ dump " not a symlink, so won't delete: $symlink_path"
+ elif [ -n "${dry_run+x}" ]; then
dump ' won'"'"'t delete an obsolete symlink, because it'"'"'s a dry run'
- fi
+ else
+ rm -f -- "$symlink_path"
- unset -v 'database[$entry]'
+ local symlink_dir
+ symlink_dir="$( dirname -- "$symlink_path" )"
- local symlink_dir
- symlink_dir="$( dirname -- "$symlink_path" )"
+ delete_obsolete_dirs "$symlink_var_dir" "$symlink_dir" || true
+ fi
- delete_obsolete_dirs "$symlink_var_dir" "$symlink_dir" || true
+ unset -v 'database[$entry]'
continue
fi