From ce261c85deadbd38c87126c2c1b3ec75c0b35857 Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sun, 8 Nov 2020 13:11:53 +0100 Subject: [PATCH] fix bug #285 --- dotdrop/cfg_yaml.py | 11 ++++++++--- dotdrop/utils.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dotdrop/cfg_yaml.py b/dotdrop/cfg_yaml.py index adcd8d0..c5ccfab 100644 --- a/dotdrop/cfg_yaml.py +++ b/dotdrop/cfg_yaml.py @@ -231,8 +231,8 @@ class CfgYaml: # add the current profile variables _, pv, pvd = self._get_profile_included_vars() - self._add_variables(pv, prio=True) - self._add_variables(pvd, shell=True, prio=True) + self._add_variables(pv, prio=False) + self._add_variables(pvd, shell=True, prio=False) self._profilevarskeys.extend(pv.keys()) self._profilevarskeys.extend(pvd.keys()) @@ -639,6 +639,11 @@ class CfgYaml: if prio: self.variables = self._merge_dict(new, self.variables) else: + # clear existing variable + for k in list(new.keys()): + if k in self.variables.keys(): + del new[k] + # merge self.variables = self._merge_dict(self.variables, new) # ensure enriched variables are relative to this config self.variables = self._enrich_vars(self.variables, self._profile) @@ -647,7 +652,7 @@ class CfgYaml: if template: # rec resolve variables with new ones self._rec_resolve_variables(self.variables) - if shell: + if shell and new: # shell exec self._shell_exec_dvars(self.variables, keys=new.keys()) # re-create the templater diff --git a/dotdrop/utils.py b/dotdrop/utils.py index 8447d5e..7a67ac8 100644 --- a/dotdrop/utils.py +++ b/dotdrop/utils.py @@ -66,7 +66,7 @@ def shell(cmd, debug=False): returns True|False, output """ if debug: - LOG.dbg('shell exec: {}'.format(cmd)) + LOG.dbg('shell exec: \"{}\"'.format(cmd)) ret, out = subprocess.getstatusoutput(cmd) if debug: LOG.dbg('shell result ({}): {}'.format(ret, out))