3 ms·
The parent comment's explanation is exactly right (although I might not use "CWD" in this context, because a reader might mistakenly think the working directory
by schoen 11y ago
The parent comment's explanation is exactly right (although I might not use "CWD" in this context, because a reader might mistakenly think the working directory is determined by an environment variable). As an example, try
python -c 'import os; os.chdir("/")'
Notice that the working directory of your shell is unaffected. :-)
Or:
bash -c 'export foo=bar'; echo $foo
- Someone1234 11y agoThose examples are trying to change the directory on the shell's child process, not on the shell itself. That being said, aside from a kernel patch there is definitely no official way of doing it. This is the hacky way: http://stackoverflow.com/questions/2375003/how-do-i-set-the-working-directory-of-the-parent-process http://stackoverflow.com/questions/2375003/how-do-i-set-the-...
- schoen 11y agoI meant for my examples just to illustrate that a child process can't change the working directory or environment of the parent process.