subprocess.Popen(..., cwd=...) and Makefile $(PWD) don't play nice

Thomas Bellman bellman at
Tue Oct 14 11:35:22 CEST 2008

Miki <miki.tebeka at> writes:

>> The problem is, he is not printing the name of the current working
>> directory; he is printing the value of the variable $PWD. =A0That is
>> likely set from the environment by the shell he started the Python
>> program from, but Python does *not* update to reflect changes to
>> the working directory.

> Should I see it as a bug? Should subprocess change this?

No, it's not a bug.  No, subprocess should not muck around with
the environment variables unless explicitly told to do so.

$PWD is only set by some (not all!) shells.  It should not be
trusted outside those shells, and hardly inside them either.

Thomas Bellman,   Lysator Computer Club,   Linköping University,  Sweden
"Adde parvum parvo magnus acervus erit"       ! bellman @
          (From The Mythical Man-Month)       ! Make Love -- Nicht Wahr!

More information about the Python-list mailing list