title: What can I do if getcwd() and getenv("PWD") don't match?
body: <p>I have a build system tool that is using <code>getcwd()</code> to get the current working directory.  That's great, except that sometimes people have spaces in their paths, which isn't supported by the build system.  You'd think that you could just make a symbolic link:</p>
  
  <pre><code>ln -s "Directory With Spaces" DirectoryWithoutSpaces
  </code></pre>
  
  <p>And then be happy.  But unfortunately for me, <code>getcwd()</code> resolves all the symbolic links.  I tried to use <code>getenv("PWD")</code>, but it is not pointing at the same path as I get back from <code>getcwd()</code>.  I blame <code>make -C</code> for not updating the environment variable, I think.  Right now, <code>getcwd()</code> gives me back a path like this:</p>
  
  <pre><code>/Users/carl/Directory With Spaces/Some/Other/Directories
  </code></pre>
  
  <p>And <code>getenv("PWD")</code> gives me:</p>
  
  <pre><code>/Users/carl/DirectoryWithoutSpaces
  </code></pre>
  
  <p>So - is there any function like <code>getcwd()</code> that doesn't resolve the symbolic links?</p>
  
  <p>Edit:</p>
  
  <p>I changed</p>
  
  <pre><code>make -C Some/Other/Directories
  </code></pre>
  
  <p>to</p>
  
  <pre><code>cd Some/Other/Directories ; make
  </code></pre>
  
  <p>And then <code>getenv("PWD")</code> works..  If there's no other solution, I can use that.</p>