diff options
author | Mat M <matm@gmx.fr> | 2019-12-08 00:25:53 +0100 |
---|---|---|
committer | Mike Burns <mburns@thoughtbot.com> | 2020-01-17 16:46:06 -0500 |
commit | f2fb351c391dca7c188a8623e71519619c2ce9a0 (patch) | |
tree | 28efb32af5fa87d62807131e85dbe1529ef23c4a /test/mkrc-no-symlinks.t | |
parent | fb8045f1cf3c8a76cba700d4e0507992be738f89 (diff) |
Do not symlink a symlink in mkrc
We have a bug when calling mkrc(1) on a symlink:
```sh
mkrc ~/.vimrc # links ~/.vimrc to ~/.dotfiles/vimrc
mkrc ~/.vimrc # deletes ~/.dotfiles/vimrc
```
This catches that case ahead of time, preventing the user from running
mkrc(1) on a symlink.
Fix #144.
Diffstat (limited to 'test/mkrc-no-symlinks.t')
-rw-r--r-- | test/mkrc-no-symlinks.t | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/mkrc-no-symlinks.t b/test/mkrc-no-symlinks.t new file mode 100644 index 0000000..e37d56a --- /dev/null +++ b/test/mkrc-no-symlinks.t @@ -0,0 +1,26 @@ + $ . "$TESTDIR/helper.sh" + +Passing a linked file is rejected. +We need a second path not under what will be $HOME + + $ EXTDIR="${CRAMTMP}2" + > mkdir -p "$EXTDIR" + > echo 'Content' > "$EXTDIR/example" + > ln -s "$EXTDIR/example" "$HOME/.example" + + $ mkrc .example + '.example' is a symlink. Cannot process file. + [1] + + $ refute "is a symlink" -h $HOME/.dotfiles/.example + +Passing a file in one linked dir is rejected + + $ mkdir "$HOME/.config" + > ln -s "$EXTDIR/" "$HOME/.config/tmpdir" + + $ mkrc -v .config/tmpdir/example + '.config/tmpdir/example' path contains a symlink (tmpdir). Cannot process file. + [1] + + $ refute "is a symlink" -h "$HOME/.dotfiles/config/tmpdir/example" |