mirror of
Fork 0

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.
This commit is contained in:
Anish Athalye 2016-08-17 18:15:02 -07:00
parent f04b94d4ae
commit 28959a3f31
2 changed files with 20 additions and 2 deletions

View File

@ -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']
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:

View File

@ -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 <<EOF
- link:
~/g: ~/f
test_expect_success 'test' '
grep "apple" ~/g