- Introduction
- Command Line Syntax
- Environment Variables
- Internal Commands
- Appendix
- EBNF
FreeCOM is a:
- Command Line Interface,
- (user) shell and/or
- COMMAND.COM replacement
for DOS. It has been spawned as part of
FreeDOS, a project that aims to implement
a GNU GPL'ed DOS.
The main duty of FreeCOM is to prompt the user to enter
commands, which
are interpreted, processed directly by FreeCOM or executed as executable
files.
Those commands processed by FreeCOM directly are called
Internal Commands.
Non-internal commands, which cannot be processed by FreeCOM directly,
are called External Commands,
because FreeCOM will search for files equally named as typed-in.
Besides to implement certain commands FreeCOM offers some
features.
COMMAND.COM [ path [ console ] ] [{ option }] [ / ( K | C ) «commandline» ]
If present, the first non-option argument specifies the location in which
FreeCOM resides. This location is later stored in the environment variable
COMSPEC. Since DOS3+ this option is no longer necessary to find the shell
invoked during the boot process, but it may be used to let the system boot
a primary shell from one location, but use a shell of the same version from
a different location later on.
One shallt not point to a RAMdisk at this, because FreeCOM needs to reload
certain information relatively early during execution, before AUTOEXEC.BAT had
been executed, in which, normally, FreeCOM is copied into the RAMdisk.
For convinience FreeCOM checks, if at the given location a FreeCOM exists
and is accessable, if not, the given location is ignored.
Also, the standard requires to specify a path only, but FreeCOM accepts
an absolute filename, so accepting that FreeCOM is not necessarily named
COMMAND.COM.
The second non-option argument, if present, specifies the console FreeCOM
shall enable. This setting is system-wide and is not limited to FreeCOM or
just this particular process tree. In its result, this argument is identical
to the CTTY command.
FreeCOM knows the following options:
- /?: Issues a help screen, then exists.
- /Y: Enables trace/single step mode. This mode is deaktivated
when the user prompt has been reached.
- /F: Enables autofail of Critical Errors; then instead of displaying
the Abort/Retry/Ignore/Fail dialog, Critical Errors are automatically answered
with Fail.
- /P: Installs a primary copy of FreeCOM. Such instance:
- cannot be terminated with the EXIT command.
- executes the AUTOEXEC.BAT script before any other command.
The /P option may have an argument to specify an alternate name for the
AUTOEXEC script, e.g.: /P:FDAUTO.BAT.
- /E: Sets another size of the environment segment, in which all the
environment variables are stored, e.g.: /E:1024.
- /L: Sets the size of the internal command buffer. Note:
This option is ignored currently, the internal buffer always defaults to 512 bytes.
- /U Sets the size of the internal user input buffer. Note:
This option is ignored currently. The input buffer always defaults to 255 bytes,
which is the maximum.
- /LOW: Forces to load FreeCOM low. Note: Currently this option
has no effect, because no part of FreeCOM is loaded high.
- /MSG: Installs the message server. Note: Because the message
server is not used nowadays, this option forces to permanently load FreeCOM's
messages into memory.
The options /K and /C are special cases and do not behave as normal
options does. They are exclusive and all characters at the right side of
such option (except an optional argument sign) specify a
command to execute, e.g.: /C DIR /s, /C=DIR /s, and /CDIR /s
do behave exactly the same and execuate the command DIR /s.
If these options are used in conjunction with the /P option, the AUTOEXEC.BAT
script is executed prior executing the specified command.
In opposite to /C the /K option enters the interactive shell
prompt after executing the specified command.
Environment variables can be freely assigned using the SET command,
e.g. executing: SET var1=tecxsgk;jsdgsdflfsjdflkasjf"lasjflas
assigns this nonsense to the variable var1. Later on, the
value of the variable can be used by writing: %var1%, thus, writing
the name of the variable enclosed without whitespace by two percent
signs.
Warning: Environment variables are expanded fully into plain
text before the command line is furtherly parsed. If a variable contains
an odd number of quotes, the remaining command line must contain the closing quote
in order to operate properly. Also see this:
SET var=text del
IF text==%var% GOTO label
The second line looks uninteresting, but once the environment variable
has been expanded the line has morphed into:
IF text==text del GOTO label
not that funny anymore, because the IF command
interpretes only the string text==text as condition, but del GOTO label
is executed as command.
FreeCOM uses a number of environment variables for its own purpose.
- COMSPEC: FreeCOM loads some information on demand, these data
are stored in the FreeCOM executable. The value of this environment variable
contains the filename FreeCOM shall use. The contents can be changed with the
SET command.
- DIRCMD: The user may define default values for the
DIR command. Any options specified within DIRCMD are prefixing any
entered ones, so to say FreeCOM behaves as if the user always types:
DIR %DIRCMD% «other arguments»
This variable must be changed using the SET command.
- COPYCMD: This variable contains default options for the
COPY command.
- PROMPT: FreeCOM prompts the user to enter commands to run, the prompt can be
customized by changing the contents of this variable.
This variable can be changed using the SET or the
PROMPT commands. Latter one includes a detailed
description of the format of the prompt string.
- PATH: When FreeCOM is to execute an external command and this one does not
contain no path, FreeCOM searched for the command in a number of paths. These ones
are enumerated by the PATH environment variable.
This variable can be changed using the SET or the
PATH commands. Latter one includes a detailed
description of the format of the search path.
There are a number of automatic variables that do not follow the above mentioned
syntax and which contents is automatically generated. Unlike the normal
variables these automatic variables are constructed of exactly two characters,
the first one is a single percent sign and the second one the variable identifier:
- %?: expands to the current errorlevel, which is the exit code of
the previously executed external command.
- %0: in batch scripts only: is the name of the script currently
executed.
- %1 through %9: in batch scripts only: are the first through nineth
argument passed to the currently executed batch script. If less than nine arguments
had been passed to the script, they return an empty string. To access the
tenth argument please refer to the SHIFT
command.
- FOR %v IN (...) DO «any command»: %v may use
any letter, the FOR command creates a new
variable, which is valid in the «any command» following the DO
keyword.
- %%: Is no real variable, but expands to a single percent sign.
Because automatic variables have one percent sign only, it sometimes lead to
confusion within the FOR command, e.g.:
SET adam=eva
FOR %a in (*.*) DO echo %adam% %a
Internal commands will be processed by FreeCOM directly, they are available
to the user without presence of any external files, in fact they hide
External Commands named equally.
The synopsises of the internal commands
are described in a style derived from EBNF.
Documents encode the synopsis of the commands with operators derived from
EBNF (Extended Backus-Naur Formula).
Type setting
Depending on different meanings characters are set into various shapes:
Name
| Meaning
| Example
|
terminal
| characters to be enterred on command line or displayed by
the computer;EBNF: "terminal symbols"
| ECHO
|
'string'
| The quotes remove the metafunction of the enclosed characters
in order to specify EBNF operators as terminal symbols.
EBNF: "terminal symbols"
| '|'
|
bold
| operators that constructs portions together;
EBNF: "operators"
| |
|
italian
| placeholders for arguments, which are explained in the description;
EBNF: "non-terminal symbols"
| varname
|
Operators
The EBNF uses the following operators:
Symbol
| Meaning
|
|
| alternative; use either left or right token
|
()
| parenthizes enclose tokens limiting the range of |
|
[]
| brackets enclose optional tokens, thus, they may appear zero or
one time; they also limit the range of |
|
{}
| curly brackets enclose repitive tokens, which may appear one or
more times; they also limit the range of |
|
{ : }
| as the normal curly brackets, but any repitive tokens are delimited
by the token(s) right of the colon; for instance:
{ file : '+' }
is the same as:
file [{ '+' file }]
and applies to:
- file
- file + file
- file + file + file
- file + file + file + file
- ...
|
« »
| is a placeholder for an arbitary string of terminal symbols, which
further syntax is described by the enclosed text in English
natural language.
|
::=
| assigns a meaning (right side) to a non-terminal symbol (left side);
for instance
DIR [ { option | filespec } ]
option ::= / ( A | B | C )
Any occurance -- only one here -- of option on the right
side of an ::= or where no ::= is present at all is
to be replaced by the right side of option::=.
|
Unless modified by above mentioned operators a sequence of tokens specifies
that each token must be present exactly one time in exactly that order.
Note: For the sake of clearness, spaces are inserted between tokens. These
spaces do not mean that a space is allowed at this place!
Also, the fact that no _ is present does not mean that
at this place is none allowed. It is assumed that the reader will find
the places where optional spaces are valid either by "doing" or by reading the
examples.
Copyright 2000 © Steffen Kaiser - current maintainer of FreeCOM