diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2016-11-11 04:21:16 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2016-11-11 04:21:16 +0300 |
commit | 3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef (patch) | |
tree | 9afc392cf1a566e8cce605c8ee35a463a3e43ada | |
parent | bugfix (diff) | |
download | config-links-3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef.tar.gz config-links-3b2ad49924dbb6142f9fc0ed8d465b37dbf6afef.zip |
don't delete obsolete files which are not symlinks
-rwxr-xr-x | update.sh | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -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 |