<?xml version="1.0" encoding="UTF-8"?>
<!-- **************************************************************************
.... For copyright and licensing terms, see the file named COPYING.
.... **************************************************************************
.-->
<?xml-stylesheet href="docbook-xml.css" type="text/css"?>

<refentry id="chdir">

<refmeta xmlns:xi="http://www.w3.org/2001/XInclude">
<refentrytitle>chdir</refentrytitle>
<manvolnum>1</manvolnum>
<refmiscinfo class="manual">user commands</refmiscinfo>
<refmiscinfo class="source">nosh</refmiscinfo>
<xi:include href="version.xml" />
</refmeta>

<refnamediv><refname>chdir</refname><refpurpose>change working directory then chain</refpurpose></refnamediv>

<refsynopsisdiv>
<cmdsynopsis>
<command>chdir</command>
<arg choice='req'><replaceable>directory</replaceable></arg>
<arg choice='req'><replaceable>next-prog</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>

<refsection><title>NOTE</title>

<para>
Most shells have a built-in <command>chdir</command> command that does not chain.
See the manual for each individual shell for its built-in command.
This command is more commonly used with <citerefentry><refentrytitle>exec</refentrytitle><manvolnum>1</manvolnum></citerefentry> and <citerefentry><refentrytitle>nosh</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
</para>

</refsection>

<refsection><title>Description</title>

<para>
<command>chdir</command> is a chain-loading utility that changes its working directory to <replaceable>directory</replaceable> and then chain loads to <replaceable>next-prog</replaceable> with the <citerefentry><refentrytitle>execvp</refentrytitle><manvolnum>3</manvolnum></citerefentry> function.
</para>

<note>
<command>chdir</command> places no requirement on the value of <replaceable>directory</replaceable> and performs no interpolation upon it.
It may be a relative instead of an absolute pathname.
Strings that begin with the <quote><code>~</code></quote> character are not processed specially.
</note>

<para>
<replaceable>next-prog</replaceable> may contain its own command line options, which <command>chdir</command> will ignore.
</para>

<para>
Unlike the shell built-in of the same name, <command>chdir</command> always operates in "physical" mode, ignores any <envar>CDPATH</envar> environment variable, and performs no canonicalization.
For the benefit of the <citerefentry><refentrytitle>pwd</refentrytitle><manvolnum>1</manvolnum></citerefentry> command when its <arg choice='plain'>-L</arg> command-line option is used, if the path of the directory changed to is an absolute one <command>chdir</command> sets the <envar>PWD</envar> environment variable to that path, and unsets that environment variable if it is a relative path.
</para>

</refsection>

<refsection><title>See also</title>

<variablelist>
<varlistentry>
<term>
<citerefentry><refentrytitle>chdir-home</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</term>
<listitem>
<para>
a chain-loading command that uses the value of the <envar>HOME</envar> environment variable
</para>
</listitem>
</varlistentry>
</variablelist>

</refsection>

<refsection><title>Author</title>
<para><author><personname><firstname>Jonathan</firstname> <surname>de Boyne Pollard</surname></personname></author></para>
</refsection>

</refentry>
