Running:
with cd('~/somewhere'):
with cd('~/somewhere'):
run('pwd')
will cause an error because of:
Executed: /bin/bash -l -c "cd /somewhere//somewhere && pwd"
but running:
with cd('/home/someuser/somewhere'):
with cd('/home/someuser/somewhere'):
run('pwd')
will work fine and return "/home/someuser/somewhere". I don't know how it works under the hood, but on the surface it seems like tilde path expressions should be treated as absolute paths instead of relative paths.
The example is somewhat silly, but came up when there are utility functions that are called by other functions, all of which need to cd into the same directory, like so:
def utility():
with cd('~/somewhere'):
run('some cmd')
def bigger_function():
with cd('~/somewhere'):
run('some other cmd')
utility()
Running:
will cause an error because of:
Executed: /bin/bash -l -c "cd
/somewhere//somewhere && pwd"but running:
will work fine and return "/home/someuser/somewhere". I don't know how it works under the hood, but on the surface it seems like tilde path expressions should be treated as absolute paths instead of relative paths.
The example is somewhat silly, but came up when there are utility functions that are called by other functions, all of which need to cd into the same directory, like so: