From: Andrei Pavel Date: Wed, 25 Jan 2023 20:38:59 +0000 (+0200) Subject: [#2696] hammer.py: replace ~ with os.environ['HOME'] X-Git-Tag: Kea-2.3.5~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39cbf167fab0f68c799f7cc299391d741b84c543;p=thirdparty%2Fkea.git [#2696] hammer.py: replace ~ with os.environ['HOME'] On rare occasion, the previously-used execute() would return empty output, which would cause the path to change, often resulting in a 'no such file or directory' error. --- diff --git a/hammer.py b/hammer.py index b86a5a54b0..01eaf489be 100755 --- a/hammer.py +++ b/hammer.py @@ -335,7 +335,7 @@ def execute(cmd, timeout=60, cwd=None, env=None, raise_error=True, dry_run=False quiet = True if cwd and "~/" in cwd: # replace relative home directory - cwd = cwd.replace('~', execute('cd ~ && pwd', capture=True, super_quiet=True)[1].rstrip()) + cwd = cwd.replace('~', os.environ['HOME']) if not super_quiet: log.info('>>>>> Executing %s in %s', cmd, cwd if cwd else os.getcwd()) if not check_times: