]> git.michaelhowe.org Git - packages/b/bup.git/commit
Remove useless code in main.py around the -d option
authorGabriel Filion <lelutin@gmail.com>
Sat, 28 Jul 2012 04:54:12 +0000 (00:54 -0400)
committerRob Browning <rlb@defaultvalue.org>
Fri, 17 Aug 2012 18:42:59 +0000 (13:42 -0500)
commit8023ad2e8a0d451b162359a94da8530c56a8c82f
tree97ad9c133cfa0674feb006dba5aa3bc87873e603
parenta6cb5328e247395ef7214bccac414247abfc5a9f
Remove useless code in main.py around the -d option

While debugging another problem with BUP_DIR, I saw a part of the
code that looked kinda suspicious (not in itself, but in the context of
the file):

  115 subcmd_env = os.environ
  116 if dest_dir:
  117     subcmd_env.update({"BUP_DIR" : dest_dir})

the subcmd_env variable is never used in main.py. However, when I
removed that part, the -d option stopped working and bup used ~/.bup
instead: so it _is_ doing what we want it to.

The reason why it's working is that line 115 is actually not creating a
copy of the dict, but rather simply pointing to the same dict. so the
call to update() actually changes the environment for the main program,
which is actually quite alright (e.g. it supercedes the environment
variable and ensures that the path given to -d is inherited into
subprocesses)

Now the problem is that this code is very not obvious about what it
does. Plus, it's a couple of useless lines that we need to maintain.
Let's just remove any extraneous work and make the addition to the
environment triggered by the -d option as obvious and concise as
possible.

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
main.py