<H3><A NAME="currdir">Current Directory</A></H3>

The current directory is the default directory of a drive.

<P>DOS stores a default directory for each drive. When a path is
specified with a drive specification only, such as <CMD>D:</CMD>,
it is completed with this default directory of that drive to
construct the <A HREF="!:abspath">absolute path</A> to be used.

<H3><A NAME="cwd">Current Working Direcory</A></H3>

In opposite to the current directory the current <EM>working</EM>
directory is the <A HREF="!:abspath">absolute path</A> constructed
out of the <A HREF="chgdrive:">currently selected drive</A> and <A
HREF="cd">current directory</A> of that drive.

<H3><A NAME="abspath">Path Specification</A></H3>

In DOS an absolute path is constructed out of several components:
<OL>
<LI>drive,
<LI>directory,
<LI>filename, and
<LI>file extension.
</OL>
like this: <CMD>D:\DIR1\DIR2\FILENAME.EXT</CMD>.

<P>The drive is a single letter from <CMD>A</CMD> through <CMD>Z</CMD>
followed by a colon <CMD>:</CMD>.

<P>The remaining part of a path consists of similiar components
delimited by a single backslash <CMD>\</CMD>. The last component
is also called filename. Each of these components may be formed of
a name, up to eight characters long, and an extension, up to
three characters long. Both parts are delimited by a single dot
<CMD>.</CMD>. Although the extension may be absent, the filename
must have at least one character.
<BR>Note: The term <EM>filename</EM> is not limited to <EM>files</EM>
in the usual sense, but may apply to any name visible in a directory,
such as subdirectories and volume labels, as well.

<P>To ease the way to enter a path the user may specify a relative path,
rather than an absolute one. In such path one or more components may
be missing:

<UL>
<LI>If no drive is specified, what means that no colon is specified, the
path is prefixed by the <A HREF="chgdrive:">currently selected
drive</A>.

<LI>If the directory is not prefixed by the backslash or no directory
is specified at all, the <A HREF="!:currdir">current directory</A>
of the drive is inserted right behind the colon.

<LI>Some programs may append an absent extension to the very last
filename component.

</UL>

<P>Examples, assume the current directories of
<TABLE BORDER=1>
<TR>
	<TD><B>Drive</B></TD>
	<TD><B>Current Directory</B></TD>
</TR>
<TR>
	<TD>C:</TD>
	<TD><CMD>\FREEDOS\HELP</CMD></TD>
</TR>
<TR>
	<TD>D:</TD>
	<TD><CMD>\TEMP\TEXT</CMD></TD>
</TR>
</TABLE>
The currently selected drive is <CMD>C:</CMD>.

<OL>
<LI><CMD>C:\</CMD>
<BR>The root directory of drive <CMD>C:</CMD>.

<LI><CMD>.</CMD>
<BR>The current working directory, ergo: <CMD>C:\FREEDOS\HELP</CMD>.

<LI><CMD>..</CMD>
<BR>The parent directory, ergo: <CMD>C:\FREEDOS</CMD>.

<LI><CMD>D:</CMD>
<BR>The current directory of drive <CMD>D:</CMD>, ergo: <CMD>D:\TEMP</CMD>.

<LI><CMD>D:.</CMD>
<BR>The current directory of drive <CMD>D:</CMD>, ergo: <CMD>D:\TEMP</CMD>.

<LI><CMD>D:..</CMD>
<BR>The parent directory of drive <CMD>D:</CMD>, ergo: <CMD>D:\</CMD>.

<LI><CMD>..\BIN</CMD>
<BR>Because there is neither a drive nor a leading backslash, both the
currently selected drive and the current directory of that drive
is inserted before the given path, ergo: <CMD>C:\FREEDOS\HELP\..\BIN</CMD>.
<BR>The embedded component <CMD>..</CMD> has the same meaning as when
specified alone: <EM>parent directory</EM>, though, here in the context
of the directory <CMD>C:\FREEDOS\HELP\</CMD>. That means that the
final absolute path is: <CMD>C:\FREEDOS\BIN</CMD>.

</OL>

<P>Path specifications that do not conform to above mentioned
format lead to various different behaviour of the various programs,
because there is no standard to scan, parse and interprete such
patterns.
Problems include:
<UL>
<LI>multiple backslashes,
<LI>multiple dots,
<LI>multiple colons, or a colon at a position unequal to two,
<LI>The current directory <CMD>.</CMD> or parent directory <CMD>..</CMD>
special directories in the context of a root directory, such as
<CMD>C:\.</CMD>, <CMD>C:\..</CMD>, or <CMD>C:\TEMP\..\..</CMD>.
</UL>

<P>Note: The special directories <CMD>.</CMD> and <CMD>..</CMD> are no
phantom directories or virtual entries, but standard entries of
every directory except the root directories. These entries help
crash recovery tools, such as <CMD>CHKDSK</CMD> or <CMD>SCANDISK</CMD>,
to find errors within the directory structure and restore it to
a valid file tree. Therefore a common assumption that a tripple dot
<CMD>...</CMD> directory means <EM>parent-of-parent</EM> is incorrect,
though, might be supported by certain programs.

<H3><A NAME="options">Standard Rules for Options</A></H3>

Options are prefixed by one forward slash &quot;<CMD>/</CMD>&quot;,
the following character identifies the option and is called
option character, for instance: <OPT>/A</OPT>

<P>Some commands do accept long option names, where a complete word
identifies the option rather than a single character, e.g. <OPT>/MSG</OPT>.

<P>Some option may be used in conjunction with an argument. The argument
is appended to the option with one colon &quot;<CMD>:</CMD>&quot; or
one equal sign &quot;<CMD>=</CMD>&quot;, for instance: <OPT>/A:hr</OPT>
or <OPT>/P=fdexec.bat</OPT>.

<P>Multiple options <EM>without</EM> argument maybe merged together
as a single option with or without embedded slashes, e.g. <OPT>/WS</OPT>
or <OPT>/W/S</OPT>, instead of <OPT>/W /S</OPT>.
<BR>However, because some commands do accept long option names, the
way with embedded slashes is more secure and is recommended therefore.
<BR>An option with argument may be the last one of such merged options.

<P>Options without arguments enable or disable certain features. Therefore,
those options are sometimes called <EM>boolean</EM> options or flags.
<BR>Boolean options may be optionally prefixed by a plus &quot;<CMD>+</CMD>&quot;
or minus &quot;<CMD>-</CMD>&quot; sign. So, the boolean option <OPT>O</OPT>
can be written in three ways:
<OL>
<LI><OPT>/+O</OPT>: The option is enabled.
<LI><OPT>/-O</OPT>: The option is disabled.
<LI><OPT>/O</OPT>: (<FONT SIZE=-1>neither plus nor minus sign</FONT>)
The option is toggled or flipped; this means if the option is
enabled currently, it is disabled; but if it is disabled currently,
it is enabled.
</OL>
<BR>Without user invention a boolean option is disabled by default, so
both <OPT>/+O</OPT> and <OPT>/O</OPT> behave the same most
of the time. However, some commands allow the user to change the default
settings of certain options, e.g. COPY and
DIR.

<H3><A NAME="redirection">I/O Redirection</A></H3>

In DOS the standard input and output can be redirected to a file or
another device; however, although it is common to use these I/O streams
today, some programmers cowardly ignore them for reasons of speed or
program size.

<P>If the <STRONG>input</STRONG> stream is redirected to a file or
device, instead of polling the keyboard and request the user to
interactively enter characters via the keyboard, those characters
are read from the file or device. Usually these programs terminate
when the file has been read wholely.

<P>If the <STRONG>output</STRONG> stream is redirected to a file
or device, instead of issuing the information onto screen,
it is dumped into the file or device. Per convention each program
has two output streams: one (called standard output)
to issue normal information and one (called standard error output) for
error messages the user should not miss.

<P>Redirections are specified on command line and effect exactly that
command invoked herein, regardless if the command is an external or
internal one, an alias or batch script. The utter exception is the FOR
command, which requires that the redirection is to apply to the command
specified behind the DO keyword rather than FOR itself.
<BR>If more than one redirection is specified on the command line and
they effect the same stream (input, output, or error), the rightmost one
superceed any previous one.

<P>Redirections are syntactically specified like this:
<BR>
EBNF: operator target
EBNF: operator ::= '<' | '>' [ '>' ] [ '&' [ '>' ] ]
EBNF: target ::= file | device

<BR>Although it is not relevant where the redirections are placed on the
command line, it is common praxis to place them at the end of it.
<P>The <ARG>operators</ARG> have the following meaning:
<TABLE BORDER>
<TR>	<TH>Operator</TH>
		<TH>Redirection</TH>
</TR>
<TR>	<TD><CMD>&lt;</CMD></TD>
		<TD>Input stream</TD>
</TR>
<TR>	<TD><CMD>&gt;</CMD></TD>
		<TD>Output stream; target file is overwritten</TD>
</TR>
<TR>	<TD><CMD>&gt;&gt;</CMD></TD>
		<TD>Output stream; output is appended to target, if it already exists</TD>
</TR>
<TR>	<TD><CMD>&gt;&amp;</CMD></TD>
		<TD>Output and error stream; target file is overwritten</TD>
</TR>
<TR>	<TD><CMD>&gt;&gt;&amp;</CMD></TD>
		<TD>Output and error stream; output is appended to target, if it already exists</TD>
</TR>
<TR>	<TD><CMD>&gt;&amp;&gt;</CMD></TD>
		<TD>Error stream; target file is overwritten</TD>
</TR>
<TR>	<TD><CMD>&gt;&gt;&amp;&gt;</CMD></TD>
		<TD>Error stream; output is appended to target, if it already exists</TD>
</TR>
</TABLE>

EXAMPLES:
EXAMPLE: 1
CMD: cmd &lt;in1 &lt;in2
<BR>Input stream is redirected to file <CMD>IN2</CMD>, because it is the rightmost
one.

EXAMPLE: 2
CMD: cmd &lt;in &gt;&amp;out
<BR>Input stream is redirected to file <CMD>IN</CMD>, output and error streams are
joined together and redireced into file <CMD>OUT</CMD>.
If the file <CMD>OUT</CMD> already exists, the old contents is discarded and
replaced by the new one; otherwise, the <CMD>OUT</CMD> is created anew.

EXAMPLE: 3
CMD: cmd &lt;in &gt;&gt;&amp;out
<BR>As example 2, but instead of replacing the contents of <CMD>OUT</CMD>, if the
file already exists, the new information is appended to the end of the file.

EXAMPLE: 4
CMD: FOR %a IN (*.*) DO ECHO %a &gt;out
<BR>As mentioned earlier, FOR is an exception and passes forth the redirections
to each invocation of the command specified right of the DO keyword. So this
examples overwrites the output file each time the ECHO command is performed,
thus, instead of creating a file list, only the last found file is recorded into
<CMD>OUT</CMD>.

EXAMPLE: 5
CMD: IF EXIST out DEL out
CMD: FOR %a IN (*.*) DO ECHO %a &gt;&gt;out
<BR>This sequence eliminate the problem, the IF command is required to
actually replace the file rather than appending the file list to the
probably existent file.

<H4>Pipes</H4>

<P>Another form of redirection is <STRONG>piping</STRONG>. Hereby, the output stream
of one command is connected to the input stream of another command. Pipes can combine
any number of commands this way. Because DOS is no multitasking system, pipes are
simulated by spawning the first command with an output redirection capturing the
issued information into a temporary file and then the second command with an input
redirection from that very same temporary file, on completation of the second
command the temporary file is deleted.

EXAMPLES:
EXAMPLE: 1
CMD: cmd1 | cmd2 | cmd3

<BR>Which is similiar to this sequence:
<BR>
CMD: cmd1 &gt;%TEMP%\t1
CMD: cmd2 &lt;%TEMP%\t1 &gt;%TEMP%\t2
CMD: DEL %TEMP%\t1
CMD: cmd3 &lt;%TEMP%\t2
CMD: DEL %TEMP%\t2

EXAMPLE: 2

The first and last command can have an input or output redirection
respectively, like so:

<BR>
CMD: cmd1 | cmd2 | cmd3 &lt;in &gt;out


<BR>Which is similiar to this sequence:
<BR>
CMD: cmd1 &gt;%TEMP%\t1 &lt;in
CMD: cmd2 &lt;%TEMP%\t1 &gt;%TEMP%\t2
CMD: DEL %TEMP%\t1
CMD: cmd3 &lt;%TEMP%\t2 &gt;out
CMD: DEL %TEMP%\t2

EXAMPLE: 3

The error stream can be piped as well:

<BR>
CMD: cmd1 |&amp; cmd2 | cmd3

<BR>Which is similiar to this sequence:
<BR>
CMD: cmd1 &gt;&amp;%TEMP%\t1
CMD: cmd2 &lt;%TEMP%\t1 &gt;%TEMP%\t2
CMD: DEL %TEMP%\t1
CMD: cmd3 &lt;%TEMP%\t2
CMD: DEL %TEMP%\t2

<BR>Here only the error messages of <CMD>cmd1</CMD> are passed
into <CMD>cmd2</CMD>; the error messages of both <CMD>cmd2</CMD>
and <CMD>cmd3</CMD> are issued to the screen.

<H4>Nested redirections</H4>

Batch scripts or when external programs invoke other programs or another shell,
redirections may be nested, e.g.:

<P>Consider the batch file <CMD>BATCH.BAT</CMD>:
<PRE>
@ECHO OFF
ECHO 1
ECHO 2 &gt;out_2
ECHO 3
</PRE>
which is invoked via:
<BR>
CMD: BATCH &gt;out_1

<BR>When the script <CMD>BATCH</CMD> gets executed, the actual output stream
is redirected to the file <CMD>OUT_1</CMD>. Therefore the output of the first
ECHO command is redirected into this file.
<BR>Because the second ECHO command has its own output redirection, its
output is redirected into the file <CMD>OUT_2</CMD>. On completion of ECHO
the redirection is closed and the former one is restored.
<BR>What causes that the output of the third ECHO command is redirected
into <CMD>OUT_1</CMD> again.


<H3><A NAME="hicmd">Hidden Internal Commands</A></H3>

There are some special internal commands, that are not directly visible
nor accessable. They are hidden because of two main purposes:
<OL>
<LI>Many of them are of internal nature and should not used by the user.
<LI>They are extensions to the normal batch language and may, therefore,
clash with a particular installation. To prevent this clash those
commands are hidden by default and can be made directly accessable
via the ICMD command.
</OL>

<P>Hidden internal commands can be access by prefixing the command
with <CMD>::=</CMD>. This token usually specifies a label within the
batch language, given the nature of the labels, they may be comments
as well. Due to the latter variant, most non-FreeCOM shells won't see
the <CMD>::=</CMD>, hence, ignore those commands.

<P>For example:
CMD: C> ::=CANCEL 30
<BR>cancels (terminates) all currently active batch files and assigns
<ARG>30</ARG> to the current errorlevel.
