From 57276995b64b87bfa79d5102d2e8101b9b616fbc Mon Sep 17 00:00:00 2001 From: Jeppe Johansen Date: Wed, 8 May 2019 16:56:33 +0200 Subject: [PATCH] Add support for expanding environment variables. Signed-off-by: Jeppe Johansen --- sbysrc/sby_core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sbysrc/sby_core.py b/sbysrc/sby_core.py index a66ea14..54e6c17 100644 --- a/sbysrc/sby_core.py +++ b/sbysrc/sby_core.py @@ -37,6 +37,14 @@ if os.name == "posix": signal.signal(signal.SIGINT, force_shutdown) signal.signal(signal.SIGTERM, force_shutdown) +def process_filename(filename): + if filename.startswith("~/"): + filename = os.environ['HOME'] + filename[1:] + + filename = os.path.expandvars(filename) + + return filename + class SbyTask: def __init__(self, job, info, deps, cmdline, logfile=None, logstderr=True): self.running = False @@ -290,8 +298,7 @@ class SbyJob: self.error("destination filename must be a relative path without /../: %s" % dstfile) dstfile = self.workdir + "/src/" + dstfile - if srcfile.startswith("~/"): - srcfile = os.environ['HOME'] + srcfile[1:] + srcfile = process_filename(srcfile) basedir = os.path.dirname(dstfile) if basedir != "" and not os.path.exists(basedir): -- 2.30.2