`any(p.startswith('~') for p in env['PATH'].split(':'))` returns a generator object expression (which will always evaluate to `True`), I think you need to do `any([p.startswith('~') for p in env['PATH'].split(':')])`. While we're at it, we should safeguard against a user not having `PATH` in `env`, so something like `if 'PATH' in env and ...` would be better.