Several command-line options are standard to all commands, or are applicable across multiple commands:
Display command line usage information.
This option, when used, must be the first option. It will be treated as an unknown option if encountered anywhere else. It should not be combined with any other options, because all other options and arguments to the command that follow it will be ignored.
The /A option allows files to be included in and excluded from processing according to their attributes. It is used with commands that accept wildcard specifications. It can optionally be supplied with an attribute mask.
When used on its own with an empty argument (i.e. /A: or /A), all files are included. The default if the /A option is not present varies from command to command (e.g. DIR includes files and directories by default; whereas COPY includes only files.).
The traditional alternative meaning for the /A option in the COPY command is not required and thus its consequent syntactic oddities are not implemented.
Prevent non-fatal error messages from being displayed.
Non-fatal errors include any errors reporting that a subdirectory contains no files during a recursive scan, or that an environment variable or alias that is being deleted doesn't exist in the first place.
The /N option causes a command to simulate operation without actually making any changes to files or to the directory structure.
The /Q option causes a command to operate quietly, without displaying information about what it is doing as it proceeds.
The /S option causes a command to operate recursively upon subdirectories. It is used with commands that accept wildcard specifications.
The /S option allows subdirectory recursion to be specified according to subdirectory attributes. It can optionally be supplied with an attribute mask.
If the attribute mask for subdirectories includes the 'D' attribute, the command will operate on the directory given in the wildcard specification and on all subdirectories beneath that directory, using the same wildcard in each directory. If the attribute mask for subdirectories does not include the 'D' attribute, the command will not recurse into subdirectories.
When used on its own with an empty argument (i.e. /S: or /S), all attributes are included, turning recursion on. The default if the /S option is not present does not include the 'D' attribute, and recursion is turned off.
Note: The FAT filesystem driver in OS/2 does not return, when searching a directory for subdirectories, any subdirectories that have the "read-only" attribute flag set. This means that on FAT volumes, commands will not recurse into subdirectories that have the read-only flag set. This is unlikely to occur, since the read-only flag has no meaning for a directory on OS/2 and is thus unlikely to have been set.
There is no workaround for this bug in the FAT filesystem driver. The HPFS filesystem driver does not have this bug, however.
The /U option prevents a command from displaying summary information, listing the total numbers of files processed, after it has processed all files and directories.
The /V option forces the verify flag to be on, causing all writes to disc to be verified by the operating system.
Note: Because of the way that IBM OS/2 works, verification simply ensures that the areas of disc that are written can subsequently be read. It does not ensure that what is read back is the same as what was written.
In OS/2, a program can receive more than one command tail when it is run. Normally, the command interpreter front ends will attempt to execute each command tail in turn as a command line.
However, this can cause problems with a rare few badly written programs that invoke a command interpreter in order to run commands, but which, because their authors hadn't read the OS/2 API documentation fully, don't properly terminate the series of command tail strings with a double-NUL character when they do so. This results in random garbage from the memory space of the calling program being passed, by the operating system, to the command interpreter as the second and subsequent command tails. Watcom's WMAKE is one such badly written program.
The /ONETAIL option is available for all of the command interpreter front
ends, and forces them to process exactly one command tail and no more,
thus ignoring the random garbage. The easiest way to pass this option to
the command interpreter is via the appropriate
CMD_XXXX_INIT environment variable.
By default, commands that display directory and file date/time stamps will display them in the standard ISO 8601 format.
The /LOCALFORMAT option causes them to instead query OS/2 for their process country settings information, and to use one of the three ("U.S.A.", "Europe", and "Japan") country-specific formats instead.
The country settings are specified by the operating system itself
reading a record from the
COUNTRY.SYS database, which is
indexed by the current country number set for the process. Changing the
date/time format information for a country involves editing that database.
Changing which country is looked up requires changing the current country
number for the process. On TAU, this is merely a matter of modifying the
COUNTRY environment variable. On IBM OS/2, the current
country number is a global setting within the kernel, which is only
modifiable by modifying
CONFIG.SYS and then rebooting the
By default, commands that display directory and file date/time stamps will
display them in the local timezone. The date/time stamps of directories
and files, as actually stored on disc, are in UTC. The system clock also
runs in UTC. These UTC values are converted to local time for display
purposes, using the timezone specified by the
TZ environment variable.
The /UTC option causes dates and times to instead be displayed in the original UTC form.
For commands that allow dates and times to be input, it also causes the command to default to UTC in the absence of an explicit timezone provided in the input. Otherwise, by default, the default timezone is taken to be the local timezone.
By default, commands that deal with source file and directory names do not treat the names differently depending from what is actually present or not present in the filesystem.
This behaviour is different to that of the commands built into the 16-bit CMD supplied with IBM OS/2. The quirky behaviour of the 16-bit CMD supplied with IBM OS/2 with respect to source names can be enabled by using the /OLDSRCDIR option. The easiest way to use this option is to set it in the initialisation environment variable that is appropriate to each individual command.
By default, commands that deal with destination file and directory names do not treat the names differently depending from what is actually present or not present in the filesystem.
This behaviour is different to that of the commands built into the 16-bit CMD supplied with IBM OS/2. The quirky behaviour of the 16-bit CMD supplied with IBM OS/2 with respect to destination names can be enabled by using the /OLDDESTDIR option. The easiest way to use this option is to set it in the initialisation environment variable that is appropriate to each individual command.
Commands parse their command tails as a series of arguments. These are either option arguments or non-option arguments.
In all commands, an option string is prefixed by the option character, which is either the forward slash, /, or the dash, -, and terminated by whitespace. The first option string encountered determines which of the two option characters will be recognised for that and all subsequent option strings.
An option string comprises a sequence of options. Options are either single-letter options, such as the standard /S option, or multiple letter options, such as the /ONETAIL option. Some options take arguments.
For options that take arguments the argument immediately follows the option without intervening whitespace. A colon is often allowed to separate the option from its argument. For example:
[c:\]dir /adsh \*
[c:\]dir /a:dsh \*
Options within a single option string are usually separated from one another by the option character, as in
Similarly, options that take arguments cannot be combined with other options and must be separated from them by the option character. As a special case, single-letter options that do not take arguments may be combined behind a single option character. For example
is the same as
although the second form is preferable, for clarity and forward compatibility.
Some options are toggles, which are either on or off. They may be followed by a plus sign, +, in order to force them to be toggled on, by a minus sign, -, in order to force them to be toggled off, or be used on their own, in which case the state of the toggle is flipped from on to off or from off to on. For example
[c:\]dir /b+ *
Options either apply globally to the entire command tail, or to the remaining part of the command tail after the option has been seen. This varies from command to command. In either case, later options always override earlier options.
In order to work with names that may begin with the option character, or to prevent the wrong option character from being recognised, a word comprising a double option character (i.e. the double dash, --, or double forward slash, //) can be used to prevent any further option characters following it from being recognised. For example:
[c:\]dir -- /os2/apps/dll
Colours are specified with the syntax
[BRIGHT] foreground colour [ON] [BRIGHT] background colour
where the foreground colours are one of "BLACK", "RED", "GREEN", "BLUE", "YELLOW", "CYAN", "MAGENTA", or "WHITE". The names of the colours and the word "BRIGHT" may be abbreviated to their first three letters.
BRIght WHIte ON BLAck
BRI RED GRE
WHITE ON BRIGHT BLUE
An attribute mask comprises a list of attributes to include, to exclude, and to require.
The attribute letters are R, A, S, H, D, and Z. The letter 'Z' is a shorthand for the combination of 'R', 'H', and 'S', which is useful for dealing with "system" files.
An attribute preceded by a minus sign, '-', excludes all files with that attribute from processing. An attribute preceded by a plus sign, '+', includes all files with that attribute in processing (i.e. a file "may have" the attribute). An attribute on its own excludes all files without that attribute from processing (i.e. a file "must have" the attribute).
For example, the mask
includes only those writable files and directories that have the hidden and system attributes, whereas the mask
includes all writable files and directories, including any that may have the hidden or system attributes.
Note: The HPFS filesystem driver in OS/2 Warp 4.0.2 and later always returns the "." entry in the root directory if it matches the wildcard being expanded, even if the applicable attribute mask would exclude it. This means that wildcards will sometimes erroneously expand to include "." when used in the root directory of HPFS volumes. This is a bug in the HPFS filesystem driver itself, not in the command interpreter or any of the external commands.