From 204871e72581b7f14ecd52a029f00b741bb6e28d Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Thu, 5 Nov 2020 22:25:31 +0100 Subject: [PATCH] ask before dereferencing symlinks for #184 --- docs/usage.md | 2 +- dotdrop/dotdrop.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/usage.md b/docs/usage.md index 5d75928..2cbf1ec 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -31,7 +31,7 @@ It can be changed: The `import` command imports dotfiles to be managed by dotdrop. It copies the dotfile to your `dotpath` and updates the config file with the new entry. -Note that dotdrop will dereference all symlinks when importing a file or directory. +Dotdrop will ask for dereferencing symlinks on import unless `-f --force` is used. For example to import `~/.xinitrc` ```bash diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index a12fd40..8189788 100644 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -374,6 +374,14 @@ def cmd_importer(o): dst = path.rstrip(os.sep) dst = os.path.abspath(dst) + if o.safe: + # ask for symlinks + realdst = os.path.realpath(dst) + if dst != realdst: + msg = '\"{}\" is a symlink, dereference it and continue?' + if not LOG.ask(msg.format(dst)): + continue + src = strip_home(dst) if o.import_as: # handle import as