Skip to content Skip to sidebar Skip to footer

Possible To Change Directory And Have Change Persist When Script Finishes?

In trying to answer a question for another user, I came across something that piqued my curiosity: import os os.chdir('..') Will change the working directory as far as Python is c

Solution 1:

There is no way to do that because calling Python or bash will run everything within their own context (that ends when the script ends).

You could achieve those results by using source, since that will actually execute your (shell) script in the current shell. i.e., call your example script with source foomaker.bash instead of bash foomaker.bash

Post a Comment for "Possible To Change Directory And Have Change Persist When Script Finishes?"