From 28959a3f31d8632975de4e18d0a0e47476b5a413 Mon Sep 17 00:00:00 2001 From: Anish Athalye Date: Wed, 17 Aug 2016 18:15:02 -0700 Subject: [PATCH] Fix user expansion in link source Previous to this patch, having a config like the following would not work properly: - link: ~/a: ~/b This was because the '~' was expanded on the left hand side (the link target), but not the right hand side (the link source). It was necessary to use a workaround like this: - link: ~/a: $HOME/b This was because variable expansion was being done, but user expansion was not being done. This commit adds support for using '~' in the link source. --- plugins/link.py | 5 +++-- .../link-environment-user-expansion-target.bash | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/tests/link-environment-user-expansion-target.bash diff --git a/plugins/link.py b/plugins/link.py index 9e1dce0..483d35e 100644 --- a/plugins/link.py +++ b/plugins/link.py @@ -30,9 +30,10 @@ class Link(dotbot.Plugin): force = source.get('force', force) relink = source.get('relink', relink) create = source.get('create', create) - path = os.path.expandvars(source['path']) + path = source['path'] else: - path = os.path.expandvars(source) + path = source + path = os.path.expandvars(os.path.expanduser(path)) if create: success &= self._create(destination) if force or relink: diff --git a/test/tests/link-environment-user-expansion-target.bash b/test/tests/link-environment-user-expansion-target.bash new file mode 100644 index 0000000..9cb3424 --- /dev/null +++ b/test/tests/link-environment-user-expansion-target.bash @@ -0,0 +1,17 @@ +test_description='link expands user in target' +. '../test-lib.bash' + +test_expect_success 'setup' ' +echo "apple" > ~/f +' + +test_expect_success 'run' ' +run_dotbot <