I can think of one way to write &quot;cd&quot; out-of-process from the shell: exec &#x2F;bin&#x2F;cd &#x2F;some&#x2F;path, which does chdir(&quot;&#x2F;some&#x2F;path&quot;) and execs your shell.  You&#x27;d lose your history and similar state, but if you had a shell that didn&#x27;t even put cd in-process, it probably doesn&#x27;t have history either.<p>Sample:<p><pre><code>    &#x2F;tmp$ exec &#x2F;tmp&#x2F;cd &#x2F;bin
    &#x2F;bin$ exec &#x2F;tmp&#x2F;cd &#x2F;home
    &#x2F;home$ exec &#x2F;tmp&#x2F;cd &#x2F;usr
    &#x2F;usr$ 
</code></pre>
Sample code:<p><pre><code>    #include &lt;err.h&gt;
    #include &lt;stdlib.h&gt;
    #include &lt;unistd.h&gt;
    
    int main(int argc, char *argv[])
    {
        char *shell;
        if (argc != 2)
            errx(1, &quot;Usage: exec cd &#x2F;some&#x2F;path&quot;);
        if (chdir(argv[1]) == -1)
            err(1, &quot;chdir&quot;);
        shell = getenv(&quot;SHELL&quot;);
        if (!shell || !*shell)
            shell = &quot;&#x2F;bin&#x2F;sh&quot;;
        execl(shell, shell, NULL);
        err(1, &quot;exec&quot;);
    }</code></pre>