title: chdir(getenv("HOME") returns Bad address
body: <pre><code>      char *home = getenv(&quot;HOME&quot;);
        if (!strcmp(t-&gt;argv[0], &quot;cd&quot;)) {
           if (!t-&gt;argv[1]) {
              chdir(home);
           }
           if (chdir(t-&gt;argv[1])) {
              perror(t-&gt;argv[1]);
           }
        }
  </code></pre>
  <p>what this is supposed to do is run the <code>cd</code> command with the provided argument, and if there is no argument provided then return to the home directory. if i call <code>cd</code> without an argument, <code>chdir</code> prints <code>&quot;Bad address&quot;</code>. i dont know why, considering i printed the value that <code>getenv(&quot;HOME&quot;)</code> returns and entered that path manually in my shell and it worked fine. why does it work when i provide the value but not when <code>getenv</code> provides it?</p>
  <p>I also cant manually code a path for home either because it has to run on other machines. i need it to work with <code>getenv(&quot;HOME&quot;)</code>.</p>