summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.md.in4
-rwxr-xr-xbin/mkrc.in4
-rw-r--r--test/mkrc-simple-output.t20
-rw-r--r--test/rcrc-custom.t2
-rw-r--r--test/rcrc.t2
5 files changed, 27 insertions, 5 deletions
diff --git a/NEWS.md.in b/NEWS.md.in
index 6e7451e..bdd68ae 100644
--- a/NEWS.md.in
+++ b/NEWS.md.in
@@ -1,7 +1,11 @@
rcm (@PACKAGE_VERSION@) unstable; urgency=low
+ * Allow running mkrc on a relative file and preserve the
+ path (Pablo Olmos de Aguilera Corradini).
* BUGFIX: Allow files with the same prefix name in the same
directory. Verbose hidden files for lsrc(1) (Javier López).
+ * Allow running mkrc on a relative file and preserve the
+ path (Pablo Olmos de Aguilera Corradini).
-- Mike Burns <mburns@thoughtbot.com> Fri, 28 Mar 2014 16:30:53 +0100
diff --git a/bin/mkrc.in b/bin/mkrc.in
index 398996a..e173eae 100755
--- a/bin/mkrc.in
+++ b/bin/mkrc.in
@@ -78,6 +78,10 @@ if [ $force_symlink -eq 1 ]; then
fi
for file in $files; do
+ case "$file" in
+ /*) break;;
+ *) [ -e "$PWD/$file" ] && file="$PWD/$file"
+ esac
dotless="$(de_dot "$file")"
dest="$(destination "$DOTFILES_DIR" "$dotless" $in_host "$tag")"
mkdir -p "$dest/$(dirname "$dotless")"
diff --git a/test/mkrc-simple-output.t b/test/mkrc-simple-output.t
index 884da01..c18886c 100644
--- a/test/mkrc-simple-output.t
+++ b/test/mkrc-simple-output.t
@@ -6,7 +6,7 @@ Making an rc file should move it into dotfiles and create a symlink
$ mkrc -v .example
Moving...
- '.example' -> '*/.dotfiles/example' (glob)
+ '*/.example' -> '*/.dotfiles/example' (glob)
Linking...
'*/.dotfiles/example' -> '*/.example' (glob)
@@ -20,7 +20,7 @@ create a symlink
$ mkrc -v .nested/example
Moving...
- '.nested/example' -> '*/.dotfiles/nested/example' (glob)
+ '*/.nested/example' -> '*/.dotfiles/nested/example' (glob)
Linking...
'*/.dotfiles/nested/example' -> '*/.nested/example' (glob)
@@ -34,8 +34,22 @@ the required directories then create a symlink
$ mkrc -v .nested/deeply/example
Moving...
- '.nested/deeply/example' -> '*/.dotfiles/nested/deeply/example' (glob)
+ '*/.nested/deeply/example' -> '*/.dotfiles/nested/deeply/example' (glob)
Linking...
'*/.dotfiles/nested/deeply/example' -> '*/.nested/deeply/example' (glob)
$ assert_linked "$HOME/.nested/deeply/example" "$HOME/.dotfiles/nested/deeply/example"
+
+Making a relative rc file being in a sub-directory should move into dotfiles
+preserving the full path then symlink
+
+ $ touch .nested/deeply/another_example
+ > cd .nested/deeply
+
+ $ mkrc -v another_example
+ Moving...
+ '*/.nested/deeply/another_example' -> '*/.dotfiles/nested/deeply/another_example' (glob)
+ Linking...
+ '*/.dotfiles/nested/deeply/another_example' -> '*/.nested/deeply/another_example' (glob)
+
+ $ assert_linked "$HOME/.nested/deeply/another_example" "$HOME/.dotfiles/nested/deeply/another_example"
diff --git a/test/rcrc-custom.t b/test/rcrc-custom.t
index ef9b8fa..658099d 100644
--- a/test/rcrc-custom.t
+++ b/test/rcrc-custom.t
@@ -9,7 +9,7 @@ mkrc should accept -r for a custom rcrc
$ RCRC=./alt-rcrc mkrc -v .example
Moving...
- '.example' -> '*/.other-dotfiles/example' (glob)
+ '*/.example' -> '*/.other-dotfiles/example' (glob)
Linking...
'*/.other-dotfiles/example' -> '*/.example' (glob)
diff --git a/test/rcrc.t b/test/rcrc.t
index 54fc022..cb1946c 100644
--- a/test/rcrc.t
+++ b/test/rcrc.t
@@ -9,7 +9,7 @@ Information should be read from ~/.rcrc by default
$ mkrc -v .example
Moving...
- '.example' -> '*/.other-dotfiles/example' (glob)
+ '*/.example' -> '*/.other-dotfiles/example' (glob)
Linking...
'*/.other-dotfiles/example' -> '*/.example' (glob)