Category : File Managers
Archive   : MS_SH164.ZIP
Filename : SH.1

 
Output of file : SH.1 contained in archive : MS_SH164.ZIP
.\"!ts -t -msqan
.\"
.\" MS-DOS SHELL - Manual Page
.\"
.\" MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited
.\"
.\" This code is subject to the following copyright restrictions:
.\"
.\" 1. Redistribution and use in source and binary forms are permitted
.\" provided that the above copyright notice is duplicated in the
.\" source form and the copyright notice in file sh6.c is displayed
.\" on entry to the program.
.\"
.\" 2. The sources (or parts thereof) or objects generated from the sources
.\" (or parts of sources) cannot be sold under any circumstances.
.\"
.\" $Header: D:/SRC/SHELL/RCS/sh.1 1.12 90/11/06 20:08:46 Ian_Stewartson Exp $
.\"
.\" $Log: sh.1 $
.\" Revision 1.12 90/11/06 20:08:46 Ian_Stewartson
.\" Add POSIX options {#%*} and ~
.\" Add builtin command
.\"
.\" Revision 1.11 90/08/14 23:17:25 Ian_Stewartson
.\" Add IO read/write open
.\"
.\" Revision 1.10 90/05/01 19:58:38 MS_user
.\" Fix typing error
.\"
.\" Revision 1.9 90/04/04 11:31:14 MS_user
.\" Change MAILPATH to use a semi-colon and not a colon for DOS
.\"
.\" Revision 1.8 90/03/28 19:42:29 MS_user
.\" Full Interrupt 24 handler included
.\"
.\" Revision 1.7 90/03/14 19:43:46 MS_user
.\" Add new initialisation file processing
.\"
.\" Revision 1.6 90/03/09 16:04:37 MS_user
.\" Add SH_BELL and SH_ALT_KEYS description
.\"
.\" Revision 1.5 90/03/06 16:03:00 MS_user
.\" Final clean up for 1.6
.\"
.\" Revision 1.4 90/03/05 13:46:27 MS_user
.\" Add functionality changes for Command Line editor
.\"
.\" Revision 1.3 90/02/22 16:55:13 MS_user
.\" Add XMS driver support
.\"
.\" Revision 1.2 90/02/16 16:58:27 MS_user
.\" Set up 1.5 release
.\"
.\" Revision 1.1 90/01/24 14:17:00 MS_user
.\" Initial revision
.\"
.\"
.\" This man page requires tbl.
.ds OK [\|
.ds CK \|]
.TH SH 1L "Data Logic Limited" "MS-DOS Version 1.6"
.SH NAME
sh, rsh - shell, the standard/restricted command programming language
.SH SYNOPSIS
\fBsh\fR [ \fB-acefhiknmrstuvx0\fR ] [ args ]
.br
\fBrsh\fR [ \fB-acefhiknmrstuvx0\fR ] [ args ]
.SH DESCRIPTION
\fISh\fR is a command programming language that executes commands read from a
terminal or a file. \fIRsh\fR is a restricted version of the standard command
interpreter \fIsh\fR; it is used to set up login names and execution
environments whose capabilities are more controlled than those of the standard
shell. See \fIInvocation\fR below for the meaning of arguments to the shell.
.SS Definitions
A \fIblank\fR is a tab or a space. A \fIname\fR is a sequence of letters,
digits, or underscores beginning with a letter or underscore. A \fIparameter\fR
is a name, a digit, or any of the characters \fB*\fR, \fB@\fR, \fB#\fR, \fB?\fR,
\fB-\fR, \fB$\fR, and \fB!\fR.
.SS Commands
A \fIsimple-command\fR is a sequence of non-blank \fIwords\fR separated by
\fIblanks\fR. The first word specifies the name of the command to be executed.
Except as specified below, the remaining words are passed as arguments to the
invoked command. The command name is passed as argument 0 (see \fIexec\fR(2)).
The \fIvalue\fR of a simple-command is its exit status if it terminates
normally, or (octal) 200+\fIstatus\fR if it terminates abnormally (see
\fIsignal\fR(2) for a list of status values).
.PP
A \fIpipeline\fR is a sequence of one or more \fIcommands\fR separated by
\fB\(bv\fR (or, for historical compatibility, by \fB^\fR).
The standard output of each command but the last is connected by a \fIpipe\fR(2)
to the standard input of the next command. Each command is run as a separate
process; the shell waits for the last command to terminate. The exit status
of a pipeline is the exit status of the last command.
.PP
A \fIlist\fR is a sequence of one or more pipelines separated by \fB;\fR,
\fB&&\fR, or \fB\(bv\(bv\fR, and optionally terminated by \fB;\fR. Of these
three symbols, \fB;\fR has a lower precedence than that of \fB&&\fR and
\fB\(bv\(bv\fR. The symbols \fB&&\fR and \fB\(bv\(bv\fR also have equal
precedence. A semicolon (\fB;\fR) causes sequential execution of the
preceding pipeline. The symbol \fB&&\fR (\fB\(bv\(bv\fR) causes the
\fIlist\fR following it to be executed only if the preceding pipeline returns
a zero (non-zero) exit status. An arbitrary number of new-lines may appear in a
\fIlist\fR, instead of semicolons, to delimit commands.
.PP
A \fIcommand\fR is either a simple-command or one of the following. Unless
otherwise stated, the value returned by a command is that of the last
simple-command executed in the command.
.PP
.PD 0
.TP
\fBfor \fIname\fR \*(OK \fBin \fIword\fR ... \*(CK \fBdo \fIlist \fBdone\fR
Each time a \fBfor\fR command is executed, \fIname\fR is set to the next
\fIword\fR taken from the \fBin\fR \fIword\fR list. If \fBin\fI word\fR ...
is omitted, then the \fBfor\fR command executes the \fBdo\fR
\fIlist\fR once for each positional parameter that is set (see \fIParameter
Substitution\fR below). Execution ends when there are no more words in the
list.
.TP
\fBcase \fIword \fBin\fR \*(OK \fIpattern\fR \*(OK \(br \
\fIpattern\fR \*(CK ... \fB) \fIlist \fB;;\fR \*(CK ... \fBesac\fR
A \fBcase\fR command executes the \fIlist\fR associated with the first
\fIpattern\fR that matches \fIword\fR. The form of the patterns is the same
as that used for file-name generation (see \fIFile Name Generation\fR) except
that a slash, a leading dot, or a dot immediately following a slash need not
be matched explicitly, and the match is case sensitive.
.TP
\fBif \fIlist \fBthen \fIlist\fR \*(OK \fBelif \fIlist \fBthen \fIlist\fR \*(CK ... \*(OK \fBelse \fIlist\fR \*(CK \fBf\&i\fR
The \fIlist\fR following \fBif\fR is executed and, if it returns a zero exit
status, the \fIlist\fR following the first \fBthen\fR is executed. Otherwise,
the \fIlist\fR following \fBelif\fR is executed and, if its value is zero, the
\fIlist\fR following the next \fBthen\fR is executed. Failing that, the
\fBelse \fIlist\fR is executed. If no \fBelse \fIlist\fR or \fBthen \fIlist\fR
is executed, then the \fBif\fR command returns a zero exit status.
.TP
\fBwhile \fIlist \fBdo \fIlist \fBdone\fR
A \fBwhile\fR command repeatedly executes the \fBwhile \fIlist\fR and, if
the exit status of the last command in the list is zero, executes the
\fBdo \fIlist\fR; otherwise the loop terminates. If no commands in the
\fBdo \fIlist\fR are executed, then the \fBwhile\fR command returns a zero
exit status; \fBuntil\fR may be used in place of \fBwhile\fR to negate the
loop termination test.
.TP
\fB(\fIlist\fB)\fR
.br
Execute \fIlist\fR in a sub-shell. The shell creates a new environment in
which to execute the \fIlist\fR, but does not fork a sub-shell as a Unix
system would. The original environment is restored on completion.
.TP
\fB{ \fIlist\fB; }\fR
.br
\fIlist\fR is simply executed.
.TP
\fIname \fB() { \fIlist\fB; }\fR
Define a function which is referenced by \fIname\fR. The body of the function
is the \fIlist\fR of commands between \fB{\fR and \fB}\fR. Execution of
functions is described below (see \fIExecution\fR).
.PD
.PP
The following words are only recognized as the first word of a command and
when not quoted:
.if t .RS
.PP
.B
.if n if then else elif fi case esac for while until do done { }
.if t if then else elif f\&i case esac for while until do done { }
.if t .RE
.SS Comments
A word beginning with \fB#\fR causes that word and all the following
characters up to a new-line to be ignored.
.SS Tilde Substitution
Each word is checked to see if it begins with an unquoted\fB~\fR. If it is,
the \fB~\fR is replaced by the value of the \fBHOME\fR parameter.
.SS Command Substitution
The standard output from a command enclosed in parenthesis preceded by a
dollar sign (\fB$()\fR), or in a pair of grave accents (\fB\(ga\(ga\fR) may
be used as part or all of a word; trailing new-lines are removed.
.SS Parameter Substitution
The character \fB$\fR is used to introduce substitutable \fIparameters\fR.
There are two types of parameters, positional and keyword. If \fIparameter\fR
is a digit, it is a positional parameter. Positional parameters may be
assigned values by \fBset\fR. Keyword parameters (also known as variables)
may be assigned values by writing:
.RS
.PP
\fIname \(eq value\fR \*(OK \fIname \(eq value\fR \*(CK ...
.RE
.PP
Pattern-matching is not performed on \fIvalue\fR. There cannot be a function
and a variable with the same \fIname\fR.
.PP
.PD 0
.TP
\fB${\fIparameter\fB}\fR
The value, if any, of the \fIparameter\fR is substituted. The braces are
required only when \fIparameter\fR is followed by a letter, digit, or
underscore that is not to be interpreted as part of its name. If
\fIparameter\fR is \fB*\fR or \fB@\fR, all the positional parameters, starting
with \fB$1\fR, are substituted (separated by spaces). Parameter \fB$0\fR is
set from argument zero when the shell is invoked.
.TP
\fB${#\fIparameter\fB}\fR
If \fIparameter\fR is \fB*\fR or \fB@\fR, the number of positional parameters
is substituted. Otherwise, the length of the value of the \fIparameter\fR is
substituted.
.TP
\fB${\fIparameter\fB:-\fIword\fB}\fR
If \fIparameter\fR is set and is non-null, substitute its value; otherwise
substitute \fIword\fR.
.TP
\fB${\fIparameter\fB:\(eq\fIword\fB}\fR
If \fIparameter\fR is not set or is null set it to \fIword\fR; the value of
the parameter is substituted. Positional parameters may not be assigned to
in this way.
.TP
\fB${\fIparameter\fB:?\fIword\fB}\fR
If \fIparameter\fR is set and is non-null, substitute its value; otherwise,
print \fIword\fR and exit from the shell. If \fIword\fR is omitted, the
message \(ga\(gaparameter null or not set\(aa\(aa is printed.
.TP
\fB${\fIparameter\fB:+\fIword\fB}\fR
If \fIparameter\fR is set and is non-null, substitute \fIword\fR; otherwise
substitute nothing.
.TP
\fB${\fIparameter\fB#\fIpattern\fB}\fR
\fB${\fIparameter\fB##\fIpattern\fB}\fR
If the Shell \fIpattern\fR matches the beginning of the value of
\fIparameter\fR, then the value of this substitution is the value of the
\fIparameter\fR with the matched portion deleted; otherwise the value of
this \fIparameter\fR is substituted. In the first form the smallest matching
\fIpattern\fR is deleted and in the latter form the largest matching
\fIpattern\fR is deleted.
.TP
\fB${\fIparameter\fB%\fIpattern\fB}\fR
\fB${\fIparameter\fB%%\fIpattern\fB}\fR
If the Shell \fIpattern\fR matches the end of the value of \fIparameter\fR,
then the value of this substitution is the value of the \fIparameter\fR with
the matched portion deleted; otherwise the value of this \fIparameter\fR is
substituted. In the first form the smallest matching \fIpattern\fR is deleted
and in the latter form the largest matching \fIpattern\fR is deleted.
.PD
.PP
In the above, \fIword\fR is not evaluated unless it is to be used as the
substituted string, so that, in the following example, \fBpwd\fR is executed
only if \fBd\fR is not set or is null:
.RS
.PP
echo ${d:-\(gapwd\(ga}
.RE
.PP
If the colon (\fB:\fR) is omitted from the above expressions, the shell only
checks whether \fIparameter\fR is set or not (\fIIt is not clear what this
means\fR).
.PP
The following parameters are automatically set by the shell:
.RS
.PD 0
.TP
.B #
The number of positional parameters in decimal.
.TP
.B \-
Flags supplied to the shell on invocation or by the \fBset\fR command.
.TP
.B ?
The decimal value returned by the last synchronously executed command.
.TP
.B $
The process number of this shell.
.TP
.B !
The process number of the last background command invoked.
.TP
.B ~
The shell reserves all variables beginning with a \fB~\fR for its own
internal use and these variables cannot be accessed by the user.
.PD
.RE
.PP
The following parameters are used by the shell:
.RS
.PD 0
.TP
.B
.SM CDPATH
The search path for the \fIcd\fR command. (Note that because a colon is used
by MSDOS to indicate a drive, a semi-colon is used to separate the path names
instead of a colon - this implies that the CDPATH variable must be set using
single or double quotes to surround the value).
.TP
.B
.SM COMSPEC
When the shell has to process an MSDOS \fI.bat\fR file, it expects the file
indicated by the value of this environment variable to be an executable
program capable of processing the MSDOS \fI.bat\fR file. The program is
invoked with the arguments \fB/c bat_file_name\fR.
.TP
.B
.SM EXTENDED_LINE
This parameter defines a file containing a list of command which can accept
an Extended Command Line using the indirect command file character \fB@\fR.
When a command which can process the Extended Command Line finds a parameter
starting with a \fB@\fR in the command list, treats the rest of the parameter
as a file and reads the parameters from that file. Examples of this
functionality include the Standard \fBLinker\fR and \fBLibrarian\fR. The
filename defined by \fBEXTENDED_LINE\fR contains a list of command (including
the .exe or .com extension) separated by a newlines. If the command is in
upper case, the file name on the command line is set up with backslashes as
the directory separator. Otherwise, slashes (Unix style) are used. This
functionality allows the user to get round the 127 byte command line length
limit of MSDOS.
.TP
.B
.SM HISTFILE
The file where command history is saved across login sessions. The default
value is \fB\s-1$HOME\s+1/history.sh\fR.
.TP
.B
.SM HOME
The default argument (home directory) for the \fIcd\fR command.
.TP
.B
.SM IFS
Internal field separators, normally \fBspace\fR, \fBtab\fR, and \fBnew-line\fR.
.TP
.B
.SM MAIL
If this parameter is set to the name of a mail file \fIand\fR the
\fB\s-1MAILPATH\s+1\fR parameter is not set, the shell informs the user of
the arrival of mail in the specified file.
.TP
.B
.SM MAILCHECK
This parameter specifies how often (in seconds) the shell will check for the
arrival of mail in the files specified by the \fB\s-1MAILPATH\s+1\fR or
\fB\s-1MAIL\s+1\fR parameters. If set to 0, the shell will check before each
prompt.
.TP
.B
.SM MAILPATH
A semi-colon (\fB;\fR) separated list of file names. If this parameter is set,
the shell informs the user of the arrival of mail in any of the specified
files. Each file name can be followed by \fB%\fR and a message that will be
printed when the modification time changes. The default message is
\fI"you have mail"\fR.
.TP
.B
.SM PATH
The search path for commands (see \fIExecution\fR below). The user may not
change \fB\s-1PATH\s+1\fR if executing under \fIrsh\fR. (Note that because a
colon is used by MSDOS to indicate a drive, a semi-colon is used to separate
the path names instead of a colon - this implies that the PATH variable must
be set using single or double quotes to surround the value). The Shell
automatically converts Unix format \fB\s-1PATH\s+1\fR assignments to MSDOS
format when appropriate. A assignment is converted if there are no semi-colons,
no backslashes and one or more colons. If there is only one colon, it must
not be the second character of the new value.
.TP
.B
.SM PS1
Primary prompt string, by default \(ga\(ga\fB$ \fR\(aa\(aa.
.TP
.B
.SM PS2
Secondary prompt string, by default \(ga\(ga\fB> \fR\(aa\(aa.
.TP
.B
.SM SHELL
When the shell is invoked, it scans the environment (see \fIEnvironment\fR
below) for this name. If it is found and there is an 'r' in the file name
part of its value, the shell becomes a restricted shell. The shell also
uses this variable to decide which program to spawn to interpret shell
scripts (see \fIExecution\fR below).
.TP
.B
.SM TMP
The location of temporary files created by the shell. If this variable is
not defined, the Shell uses the \fB\s-1HOME\s+1\fR directory for temporary
files. Failing that, the root directory of the current drive is used.
.RE
.PP
.sp
The shell gives default values to \fB\s-1PATH\s+1\fR, \fB\s-1PS1\s+1\fR,
\fB\s-1PS2\s+1\fR, \fB\s-1SHELL\s+1\fR, \fB\s-1HOME\s+1\fR and
\fB\s-1IFS\s+1\fR.
.sp
.SS Blank Interpretation
After parameter and command substitution, the results of substitution are
scanned for internal field separator characters (those found in
\fB\s-1IFS\s+1\fR) and split into distinct arguments where such characters
are found. Explicit null arguments (\fB""\fR or \fB\(aa\(aa\fR) are retained.
Implicit null arguments (those resulting from \fIparameters\fR that have no
values) are removed.
.SS File Name Generation
Following substitution, each command \fIword\fR is scanned for the characters
\fB*\fR, \fB?\fR and \fB\*(OK\fR. If one of these characters appears the word
is regarded as a \fIpattern\fR. The word is replaced with alphabetically
sorted file names that match the pattern. If no file name is found that
matches the pattern, the word is left unchanged. The character \fB.\fR at the
start of a file name or immediately following a \fB/\fR, as well as the
character \fB/\fR itself, must be matched explicitly. When matching
patterns for file names, the shell ignores the case of the pattern and the
file directory entries. Generated file names are always in lower case.
.PP
.PD 0
.RS
.TP
\fB*\fR
Matches any string, including the null string.
.TP
\fB?\fR
Matches any single character.
.TP
\fB\*(OK ... \*(CK\fR
Matches any one of the enclosed characters. A pair of characters separated by
\fB-\fR matches any character lexically between the pair, inclusive. If the
first character following the opening \(ga\(ga\*(OK\(aa\(aa is a
\fB\(ga\(ga!\(aa\(aa\fR any character not enclosed is matched.
.PD
.RE
.PP
If the shell has to open or create the file \fB/dev/tty\fR or \fB/dev/null\fR
(which are Unix special files), they are converted to the equivalent MSDOS
file names (\fB/dev/con\fR and \fB/dev/nul\fR respectively). Any user
programs which could expect \fB/dev/tty\fR or \fB/dev/null\fR as
arguments must do its own mapping to the MSDOS equivalents.
.SS Quoting
The following characters have a special meaning to the shell and cause
termination of a word unless quoted:
.RS
.PP
\fB; & ( ) \(br ^ < > new-line space tab\fR
.RE
.PP
A character may be \fIquoted\fR (i.e., made to stand for itself) by preceding
it with a \fB\e\fR. The pair \fB\enew-line\fR is ignored. All characters
enclosed between a pair of single quote marks (\fB\(aa\(aa\fR), except a
single quote, are quoted. Inside double quote marks (\fB""\fR), parameter
and command substitution occurs and \fB\e\fR quotes the characters \fB\e\fR,
\fB\(ga\fR, \fB"\fR, and \fB$\fR. \fB"$*"\fR is equivalent to \fB"$1 $2 ..."\fR,
whereas \fB"$@"\fR is equivalent to \fB"$1" "$2" ...\fR.
.SS Prompting
When used interactively, the shell prompts with the value of \fBPS1\fR
before reading a command. If at any time a new-line is typed and further
input is needed to complete a command, the secondary prompt (i.e., the value
of \fB\s-1PS2\s+1\fR) is issued.
.PP
Many people like to have the shell provide them with useful information in
their prompt. To accommodate this, the shell recognises special sequences of
characters in the values of \fBPS1\fR and \fBPS2\fR, and substitutes the
appropriate information for them. The special sequences and what they signify
are:
.RS
.TP
\fB%d\fR
Place the current date, in the form \s-1DAY DD-MM-YY\s+1 into the prompt.
.TP
\fB%e\fR
Place the current event number (as defined by the \fBhistory\fR command) into
the prompt. If history evaluation has been turned off (via \fBhistory -d\fR),
no number will be substituted in (i.e. the \fB%e\fR will be removed).
.TP
\fB%n\fR
Place the current working drive into the prompt.
.TP
\fB%p\fR
Place the current working directory into the prompt.
.TP
\fB%t\fR
Place the current time of day, in the form \s-1HH:MM\s+1 into the prompt.
The time is on a 24 hour clock, i.e. 1:30 in the afternoon will be 13:30.
.TP
\fB%v\fR
Place the MSDOS version number, in the form \s-1 MSDOS MM:MM\s+1 into the
prompt.
.TP
\fB%%\fR
Place the character \fI%\fR into the prompt.
.TP
\fB\exxx\fR
Place the character \fI\exxx\fR into the prompt. The processing of escape
sequences is the same as that for \fBecho\fR.
.RE
.PP
Some of these facilities are of more use than others.
.SS Input/Output
Before a command is executed, its input and output may be redirected using a
special notation interpreted by the shell. The following may appear anywhere
in a simple-command or may precede or follow a \fIcommand\fR and are \fInot\fR
passed on to the invoked command; substitution occurs before \fIword\fR or
\fIdigit\fR is used:
.PP
.PD 0
.TP 14
\fB Use file \fIword\fR as standard input (file descriptor 0).
.TP
\fB>word\fR
Use file \fIword\fR as standard output (file descriptor 1). If the file does
not exist it is created; otherwise, it is truncated to zero length.
.TP
\fB>\[email protected]@>word\fR
Use file \fIword\fR as standard output. If the file exists output is appended
to it (by first seeking to the end-of-file); otherwise, the file is created.
.TP
\fB<\[email protected]@<\fR\*(OK\fB-\fR\*(CK\fBword\fR
The shell input is read up to a line that is the same as \fIword\fR, or to an
end-of-file. The resulting document becomes the standard input. If any
character of \fIword\fR is quoted, no interpretation is placed upon the
characters of the document; otherwise, parameter and command substitution
occurs, (unescaped) \fB\enew-line\fR is ignored, and \fB\e\fR must be used to
quote the characters \fB\e\fR, \fB$\fR, \fB\(ga\fR, and the first character of
\fIword\fR. If \fB-\fR is appended to \fB<\[email protected]@<\fR, all leading tabs are
stripped from \fIword\fR and from the document.
.TP
\fB<\[email protected]@&digit\fR
Use the file associated with file descriptor \fIdigit\fR as standard input.
Similarly for the standard output using \fB>\[email protected]@&digit\fR.
.TP
\fB<\[email protected]@&\[email protected]@\-\fR
The standard input is closed. Similarly for the standard output using
\fB>\[email protected]@&\[email protected]@\-\fR.
.TP
\fBn<\[email protected]@>word\fR
causes the file \fIword\fR to be opened on file descriptor \fIn\fR for both
reading and writing. The file must already exist.
.PD
.PP
If any of the above is preceded by a digit, the file descriptor which will be
associated with the file is that specified by the digit (instead of the
default 0 or 1). For example:
.RS
.PP
\&... 2>&1
.RE
.PP
associates file descriptor 2 with the file currently associated with file
descriptor 1.
.PP
The order in which redirections are specified is significant. The shell
evaluates redirections left-to-right. For example:
.RS
.PP
\&... 1>\fIxxx\fR 2>&1
.RE
.PP
first associates file descriptor 1 with file \fIxxx\fR. It associates file
descriptor 2 with the file associated with file descriptor 1 (i.e. \fIxxx\fR).
If the order of redirections were reversed, file descriptor 2 would be
associated with the terminal (assuming file descriptor 1 had been) and file
descriptor 1 would be associated with file \fIxxx\fR .
.PP
The environment for the execution of a command contains the file descriptors
of the invoking shell as modified by input/output specifications.
.PP
Redirection of output is not allowed in the restricted shell.
.SS Environment
The \fIenvironment\fR (see \fIenviron\fR(5)) is a list of name-value pairs
that is passed to an executed program in the same way as a normal argument
list. The shell interacts with the environment in several ways. On invocation,
the shell scans the environment and creates a parameter for each name found,
giving it the corresponding value. If the user modifies the value of any of
these parameters or creates new parameters, none of these affects the
environment unless the \fBexport\fR command is used to bind the shell's
parameter to the environment (see also \fBset -a\fR). A parameter may be
removed from the environment with the \fBunset\fR command. The environment
seen by any executed command is thus composed of any unmodified name-value
pairs originally inherited by the shell, minus any pairs removed by \fBunset\fR,
plus any modifications or additions, all of which must be noted in \fBexport\fR
commands.
.PP
The environment for any \fIsimple-command\fR may be augmented by prefixing it
with one or more assignments to parameters. Thus:
.RS
.PP
\s-1TERM\s+1\(eq450 cmd args and
.br
(export \s-1TERM\s+1; \s-1TERM\s+1\(eq450; cmd args)
.RE
.PP
are equivalent (as far as the execution of \fIcmd\fR is concerned).
.PP
If the \fB-k\fR flag is set, \fIall\fR keyword arguments are placed in the
environment, even if they occur after the command name. The following first
prints \fBa\(eqb c\fR and \fBc\fR:
.PP
.RS
.nf
echo a\(eqb c
set -k
echo a\(eqb c
.fi
.RE
.SS Signals
The \s-1INTERRUPT\s+1 and \s-1QUIT\s+1 signals for an invoked command are
ignored if the command is followed by \fB&\fR; otherwise signals have the
values inherited by the shell from its parent, with the exception of signal 11
(but see also the \fBtrap\fR command below).
.SS History
When reading input from an interactive terminal, a \(ga\(ga!\(aa\(aa at the
start of a line signals to the shell that it should attempt to perform a history
subsitution. A history subsitution is a short-hand method which allows the
user to recall a previous command for execution or editing. The recalled
command is placed in the command line for editing or passing to the rest of
the shell for normal processing. A history substitution takes the form:
.RS
.PP
\fB!\fR \*(OK ! \(br \fIstr\fR \(br \fInum\fR \*(CK \fIterminator\fR
.RE
.PP
\fB!!\fR will place the previous command in the command line.
\fB!\fInum\fR will place the history command with the specified number
in the command line. \fB!\fIstr\fR will find the most recent command
line that started with the characters in \fIstr\fR.
.PP
The \fIterminator\fR determines what action is performed after the history
line has been found. If the original history command is entered using the
\fB\fR key, the new command line is passed directly to the shell.
If the \fB\fR key is pressed, the new command line can be edited in the
manner described below.
.SS Command Line Editing
When reading input from an interactive terminal, certain keystrokes allow
the current input line to be edited. The following keystrokes
corresponding to the following functions are defined in the initialisation
file \fBsh.ini\fR. The keywords in the initialisation file which provide
the functions are listed below:
.TP
.B
.SM "Right"
Move the cursor right one character
.TP
.B
.SM "WordRight"
Move the cursor right one word
.TP
.B
.SM "Left"
Move the cursor left one character
.TP
.B
.SM "WordLeft"
Move the cursor left one word
.TP
.B
.SM "Previous"
Get the previous command from the history file
.TP
.B
.SM "Next"
Get the next command from the history file
.TP
.B
.SM "Insert"
Toggle insert/overwrite mode (note the shape of the cursor changes to
indicate the current mode)
.TP
.B
.SM "DeleteRight
Delete the current character unless the cursor is at the end of line when
no action is taken
.TP
.B
.SM "Start"
Move the cursor to the start of the command
.TP
.B
.SM "Complete"
Attempt to complete the filename. The shell attempts to complete the file
name at the current cursor position. The file name is delimited by white
space characters. If the shell is unable to complete the file name (ie no
match can be found in the appropriate directory), the bell is rung. If a
single match is found, the new file name is displayed. If multiple matches
are found, the file name is replaced by the longest non-unique part of the
file name and the bell is rung.
.TP
.B
.SM "End"
Move the cursor to the end of the command, unless the first character of
the command is a \fB!\fR, in which case the appropriate history search is
done. The cursor is placed at the end of the command line.
.TP
.B
.SM "Flush"
Delete to the end of the line
.TP
.B
.SM "ScanBackward"
Search backwards from the current history command for the next match against
the last history request or the string currently in the command line if
there has been no previous history request.
.TP
.B
.SM "ScanForeward"
Search forewards from the current history command for the next match against
the last history request or the string currently in the command line if
there has been no previous history request.
.TP
.B
.SM "Clear"
Erase the complete line.
.TP
.B
.SM "Directory"
Display the file name list matching the partially entered file name under
the cursor. If no matches are found the bell is rung. To display the
whole directory, enter the directory name followed by a slash \fB/\fR.
After the directory listing has been displayed, the entered command line is
redisplayed.
.TP
.B
.SM "DeleteLeft"
Delete the character to the left of the cursor.
.TP
.B
.SM "Return"
Execute the command line, unless the first character of the command is a
\fB!\fR, in which case the appropriate history processing is done. \fIThis
is the actual key pressed and cannot be modified by the initialisation file.\fR
.PD
.RE
.SS Initialisation File
When the shell is run in interactive mode, the Command Line Editing keys
and other user configuration parameters are read from the initialisation
file \fIsh.ini\fR. This shell looks for this file in the same directory as
the \fBsh\fR executable which is running. It does not use the \fBSHELL\fR
environment variable or search the directories in the \fBPATH\fR
environment variable. At present, there are two types of entry in this
file: keyboard configuration; and others. The entry is contained in a
single line and consists of a keyword (in upper or lower case), white space,
an equals symbols, white space and one or two numeric values (see \fIstrtol\fR
for valid formats where \fIbase\fR parameter is zero), followed by an end
of line character.
.PP
For the keyboard entries, the numeric values give the MSDOS Function 8 (Console
Input without Echo) return values for that entry. Note that extended codes
(function keys) require two calls to this function. The first call returns
zero and the second the extended code. In the configuration file, a first
numeric value of zero indicates a extended code and must be followed by a
second value. A non-zero first numeric value must not be followed by
anything else on the line.
.PP
Other entries must only have one numeric value. A zero value disables the
function and a non-zero value enables the function. At present, there are
two other functions:
.TP
.B
.SM "Bell"
Enable/disable warning bells
.TP
.B
.SM "HalfHeight"
Use full or halfheight block cursor to indicate Insert mode
.PD
.RE
.PP
Invalid lines or lines beginning with a \fB#\fR are ignored.
.PP
The following table gives the list of valid keywords and their default
values:
.TS
box;
l l l l.
Keyword First numeric Second numeric Actual Key
_
KEYBOARD ENTRIES
ScanBackward 0 0x49 PAGE UP
ScanForeward 0 0x51 PAGE DOWN
Previous 0 0x48 UP ARROW
Next 0 0x50 DOWN ARROW
Left 0 0x4b LEFT ARROW
Right 0 0x4d RIGHT ARROW
WordRight 0 0x74 Control RIGHT ARROW
WordLeft 0 0x73 Control LEFT ARROW
Start 0 0x47 HOME
Clear 0 0x76 Control PAGE DOWN
Flush 0 0x75 Control END
End 0 0x4f END
Insert 0 0x52 INSERT
DeleteRight 0 0x53 DELETE
DeleteLeft 0x08 BACKSPACE
Complete 0 0x77 Control HOME
Directory 0 0x0f Shift TAB
_
OTHER FUNCTIONS
Bell 0
HalfHeight 0
.TE
.SS Execution
Each time a command is executed, the above substitutions are carried out. If
the command name matches one of the \fISpecial Commands\fR listed below, it
is executed in the shell process. If the command name does not match a
\fISpecial Command\fR, but matches the name of a defined function, the
function is executed in the shell process (note how this differs from the
execution of shell procedures). The positional parameters \fB$1\fR,
\fB$2\fR, .... are set to the arguments of the function. If the command
name matches neither a \fISpecial Command\fR nor the name of a defined function,
a new process is created and an attempt is made to execute the command via
\fIexec\fR(2).
.PP
The shell parameter \fBPATH\fR defines the search path for the directory
containing the command. Alternative directory names are separated by a
semi-colon (\fB;\fR). The default path is \fB;c:/bin;c:/usr/bin\fR (specifying
the current directory, \fBc:/bin\fR, and \fBc:/usr/bin\fR, in that order).
Note that the current directory is specified by a null path name, which can
appear immediately after the equal sign or between the semi-colon delimiters
anywhere else in the path list. If the command name contains a \fB/\fR or
starts with \fBx:\fR (where x is a drive letter) the search path is not used;
such commands will not be executed by the restricted shell. Otherwise, each
directory in the path is searched for an executable file. Executable files
are indicated by a .exe or .com extension. This extension is automatically
supplied by the shell and not have to be entered by the user.
.PP
If the file with a .com or .exe extension cannot be found in the
directory, the file is opened and first 512 characters are read. If there are
no characters in the block with a value in the range 0 to 7, the file is
assumed to be a script file containing shell commands. Note that the shell
will check the file and if that file does not exist or is not a script, it
will try the file with an extension of \fB.sh\fR. If a \fB.sh\fR file is
found, that will be processed. A sub-shell (given by the environment
variable \fBSHELL\fR) is spawned to read
it.
.PP
If the script file starts with the a line of the form \fI#! interpreter\fR
\*(OK\fIarguments\fR\*(CK, the interpreter is invoked instead of the shell
to process the script. Optional arguments can be supplied in the script
file which are passed before the name of the script file. Thus, if the
file \fIdemo\fR contained the following string as the first line
.RS
.PP
#! perl -sP
.RE
.PP
Entering \fIdemo name\fR would be equivalent to entering the \fIperl -sP name\fR
at the command prompt. Note that no other processing of the first line
other that the separation (by white space) into arguments is done.
.PP
If none of the above conditions for a executable file are detected and a file
with a .bat extension exists in the directory, the command processor given by
the \fBCOMSPEC\fR environment variable is spawned to process the file. This
is normally the standard MSDOS \fIcommand.com\fR processor.
.PP
A parenthesized command is also executed in a sub-shell.
.SS Special Commands
Input/output redirection is permitted for these commands. File descriptor 1
is the default output location.
.PP
.PD 0
.TP
\fB:\fR
No effect; the command does nothing. A zero exit code is returned.
.TP
\fIletter\fB:\fR
Select the drive specified by \fIletter\fR.
.TP
\fB\&. \fIfile\fR
Read and execute commands from \fIfile\fR and return. The search path
specified by \fBPATH\fR is used to find the directory containing \fIfile\fR.
.TP
\fBbreak\fR \*(OK \fIn\fR \*(CK
Exit from the enclosing \fBfor\fR or \fBwhile\fR loop, if any. If \fIn\fR is
specified, break \fIn\fR levels.
.TP
\fBbuiltin\fR \*(OK \fIargs\fR ... \*(CK
Force the selection of the \fBbuiltin\fR version of a command. The builtin
shell command selected by the first \fIargs\fR value is executed with the
parameters defined by the remaining \fIargs\fRs. If no arguments are given,
a list of all \fIbuiltin\fR commands is printed.
.sp
If the first argument is one of the following, the processing of the
builtin command in the following arguments are changed as indicated:
.RS
.TP
\fB-a\fR
Set the following builtin commands to use builtin version in preference to
any function or external versions.
.TP
\fB-d\fR
Set the following builtin commands to use the function or external version
in preference to the builtin version.
.TP
\fB-s\fR
Display the current status of the following builtin commands.
.RE
.TP
\fBcontinue\fR \*(OK \fIn\fR \*(CK
Resume the next iteration of the enclosing \fBfor\fR or \fBwhile\fR loop. If
\fIn\fR is specified, resume at the \fIn\fR-th enclosing loop.
.TP
\fBcd\fR \*(OK \fIarg\fR \*(CK
Change the current directory to \fIarg\fR. The shell parameter \fBHOME\fR is
the default \fIarg\fR. The shell parameter \fBCDPATH\fR defines the search
path for the directory containing \fIarg\fR. Alternative directory names are
separated by a semi-colon (\fB;\fR). The default path is \fB\fR
(specifying the current directory). Note that the current directory is
specified by a null path name, which can appear immediately after the equal
sign or between the semi-colon delimiters anywhere else in the path list.
If \fIarg\fR begins with a \fB/\fR or \fBx:\fR (where x is a drive letter),
the search path is not used. Otherwise, each directory in the path is searched
for \fIarg\fR. The \fIcd\fR command may not be executed by \fIrsh\fR.
.TP
\fBecho\fR \*(OK \fIarg\fR ... \*(CK
Echo arguments. \fBEcho\fR writes its arguments separated by blanks and
terminated by a new-line on the standard output. It also understands C-like
escape conventions; beware of conflicts with the shell's use of \fB\e\fR:
.PP
.RS
.PD 0
.TP
\fB\eb\fR
backspace
.TP
\fB\ec\fR
print line without new-line
.TP
\fB\ef\fR
form-feed
.TP
\fB\en\fR
new-line
.TP
\fB\er\fR
carriage return
.TP
\fB\et\fR
tab
.TP
\fB\ev\fR
vertical tab
.TP
\fB\e\e\fR
backslash
.TP
\fB\e\fIn\fR
the 8-bit character whose \s-1ASCII\s0 code is the 1-, 2- or 3-digit octal
number \fIn\fR, which must start with a zero.
.PD
.PP
\fIEcho\fR is useful for producing diagnostics in command files and for
sending known data into a pipe.
.RE
.TP
\fBeval\fR \*(OK \fIarg\fR ... \*(CK
The arguments are read as input to the shell and the resulting command(s)
executed.
.TP
\fBexec\fR \*(OK \fIarg\fR ... \*(CK
The command specified by the arguments is executed in place of this shell
without creating a new process. Input/output arguments may appear and, if no
other arguments are given, cause the shell input/output to be modified.
.TP
\fBexit\fR \*(OK \fIn\fR \*(CK
Causes a shell to exit with the exit status specified by \fIn\fR.
If \fIn\fR is omitted the exit status is that of the last command executed
(an end-of-file will also cause the shell to exit.)
.TP
\fBexport\fR \*(OK \fIname\fR ... \*(CK
The given \fIname\fRs are marked for automatic export to the \fIenvironment\fR
of subsequently-executed commands. If no arguments are given, a list of all
names that are exported in this shell is printed. Function names may \fInot\fR
be exported.
.TP
\fBgetopt\fR \fIoptstring name\fR \*(OK \fIargs\fR ... \*(CK
Parse command options and write them to standard output. \fBGetopt\fR is used
to break up options in command lines for easy parsing by shell procedures and
to check for legal options. \fIOptstring\fR is a string of recognized option
letters (see \fIgetopt\fR(3C)); if a letter is followed by a colon, the option
is expected to have an argument which may or may not be separated from it by
white space. The special option \fB\-\-\fP is used to delimit the end of the
options. If it is used explicitly, \fBgetopt\fR will recognize it; otherwise,
\fBgetopt\fR will generate it; in either case, \fBgetopt\fR will place it at
the end of the options. Each option is preceded by a \fB-\fR and is in its
own positional parameter; each option argument is also parsed into its own
positional parameter.
.sp
The following code fragment shows how one might process the arguments for a
command that can take the options \fBa\fR or \fBb\fR, as well as the option
\fBo\fR, which requires an argument:
.sp
.RS
.nf
.ss 18
.ta +.5i +1i
set -- \(gagetopt abo: $*\(ga
if [ $? !\(eq 0 ]
then
echo $\s-1USAGE\s+1
exit 2
fi
for i in $\(**
do
case $i in
\-a \(bv \-b) \s-1FLAG\s+1\(eq$i; shift;;
\-o) \s-1OARG\s+1\(eq$2; shift 2;;
\-\-) shift; break;;
esac
done
.fi
.ta
.ss 12
.sp
This code will accept any of the following as equivalent:
.sp
.nf
.ss 18
cmd \-aoarg file file
cmd \-a \-o arg file file
cmd \-oarg \-a file file
cmd \-a \-oarg \-\- file file
.fi
.ss 12
.RE
.TP
\fBhistory\fR \*(OK \fB-dei\fR \*(CK
The \fBhistory\fR command, with no arguments, will print all the commands that
are currently saved in the shell's history buffers. As new commands are
executed, and space in the buffers runs out, old commands will be deleted. The
\fBhistory\fR commands prints out the stored commands with sequence numbers.
Negative numbered commands, through command number zero, are commands that were
retrieved from the saved history file. Commands starting at one were entered
during the current login session. If a saved command contains embedded
newlines, these will be printed out as the sequence \fB\en\fR, so that
individual command stay on one line.
.sp
The arguments changes the way the shell processes history information as
follows:
.RS
.TP
\fB-d\fR
Disable the saving of commands in the history file.
.TP
\fB-e\fR
Enable the saving of commands in the history file.
.TP
\fB-i\fR
Initialise the history file.
.RE
.TP
\fBmsdos\fR \*(OK \fIname\fR ... \*(CK
The given \fIname\fRs are marked \fImsdos\fR format and if the \fB-m\fR flag
is set, the values of the these \fIname\fRs are exported to child processes
with any slashes in the value replaced by backslashes. If no arguments are
given, a list of all \fImsdos\fR names is printed.
.TP
\fBpwd\fR
Print the current working directory.
.TP
\fBread\fR \*(OK \fIname\fR ... \*(CK
One line is read from the standard input and the first word is assigned to the
first \fIname\fR, the second word to the second \fIname\fR, etc., with leftover
words assigned to the last \fIname\fR. The return code is 0 unless an
end-of-file is encountered.
.TP
\fBreadonly\fR \*(OK \fIname\fR ... \*(CK
The given \fIname\fRs are marked \fIreadonly\fR and the values of the these
\fIname\fRs may not be changed by subsequent assignment. If no arguments are
given, a list of all \fIreadonly\fR names is printed.
.TP
\fBreturn\fR \*(OK \fIn\fR \*(CK
Causes a function to exit with the return value specified by \fIn\fR. If
\fIn\fR is omitted, the return status is that of the last command executed.
.TP
\fBset\fR \*(OK \fB--aefkmntuvx\fR \*(OK \fIarg\fR ... \*(CK \*(CK
.RS
.TP
\fB-a\fR
Mark variables which are modified or created for export.
.TP
\fB-e\fR
Exit immediately if a command exits with a non-zero exit status.
.TP
\fB-f\fR
Disable file name generation
.TP
\fB-k\fR
All keyword arguments are placed in the environment for a command, not just
those that precede the command name.
.TP
\fB-m\fR
For those variables marked as \fBmsdos\fR variables, the values are
exported to child processes with the slashes replaced by backslashes. Most
MSDOS utilities do not care if a file name contains a slash or backslash as
a directory separator. However, some like the \fIlinker\fR require
backslashes in the value of the \fBLIB\fR variable.
.TP
\fB-n\fR
Read commands but do not execute them.
.TP
\fB-t\fR
Exit after reading and executing one command.
.TP
\fB-u\fR
Treat unset variables as an error when substituting.
.TP
\fB-v\fR
Print shell input lines as they are read.
.TP
\fB-x\fR
Print commands and their arguments as they are executed.
.TP
\fB--\fR
Do not change any of the flags; useful in setting \fB$1\fR to \fB\-\fR.
.PP
Using \fB+\fR rather than \fB-\fR causes these flags to be turned off. These
flags can also be used upon invocation of the shell. The current set of flags
may be found in \fB$-\fR. The remaining arguments are positional parameters
and are assigned, in order, to \fB$1\fR, \fB$2\fR, .... If no arguments
are given the values of all names are printed.
.RE
.TP
\fBshift\fR \*(OK \fIn\fR \*(CK
.br
The positional parameters from \fB$n+1\fR ... are renamed \fB$1\fR .... If
\fIn\fR is not given, it is assumed to be 1.
.TP
\fBswap\fR \*(OK \fIoptions\fR \*(CK
This command defines how the shell will handle swapping. The options are
.RS
.TP
\fBoff\fR
Disable swapping. The shell remains in memory whilst the child is running
and reduces the available memory by about 200K (depending on the size of
the environment and history).
.TP
\fBon\fR
Enable all devices. The shell will swap out to either expanded or extended
memory or to disk, execute the command and then swap back in. Whilest
swapped, the shell reduces the available memory by about 3K.
.TP
\fBexpand\fR
Enable swapping to Expanded Memory. The EMS driver must exist on your
system for this to work.
.TP
\fBextent\fR \*(OK \fIstart address\fR \*(CK
Enable swapping to Extended Memory. If you have an XMS driver on your
system, the shell will use the XMS driver. Otherwise, the BIOS Interrupt
15 interface is used. The optional start address defines the based address
in the Extended Memory at which point the shell writes its swap area when
the BIOS interface is used. The default location is \fI0x100000\fR.
.TP
\fBdisk\fR
Enable swapping to disk. The shell creates a temporary file and saves
itself in it. On completion, the file is deleted. This is the slowest method
of swapping.
.PD
.PP
With no options, the current swapping options are displayed.
.RE
.TP
\fBtest \fIexpr\fR or \fB\*(OK \fIexpr\fB \*(CK\fR
Evaluate conditional expressions. \fBTest\fR evaluates the expression
\fIexpr\fR and, if its value is true, returns a zero (true) exit status;
otherwise, a non-zero (false) exit status is returned; \fBtest\fR also returns
a non-zero exit status if there are no arguments. The following primitives
are used to construct \fBexpr\fR:
.RS
.TP 12
\fB-r \fIfile\fR
true if \fIfile\fR exists and is readable.
.TP
\fB-w \fIfile\fR
true if \fIfile\fR exists and is writable.
.TP
\fB-x \fIfile\fR
true if \fIfile\fR exists and is executable.
.TP
\fB-f \fIfile\fR
true if \fIfile\fR exists and is a regular file.
.TP
\fB-d \fIfile\fR
true if \fIfile\fR exists and is a directory.
.TP
\fB-c \fIfile\fR
true if \fIfile\fR exists and is a character special file.
.TP
\fB-b \fIfile\fR
true if \fIfile\fR exists and is a block special file.
.TP
\fB-s \fIfile\fR
true if \fIfile\fR exists and has a size greater than zero.
.TP
\fB-t\fR \*(OK \fIfildes\fR \*(CK
true if the open file whose file descriptor number is \fIfildes\fR (1 by
default) is associated with a terminal device.
.TP
\fB-z \fIs1\fR
true if the length of the string \fIs1\fR is zero.
.TP
\fB-n \fIs1\fR
true if the length of the string \fIs1\fR is non-zero.
.TP
\fIs1 \fB\(eq\fI s2\fR
true if strings \fIs1\fR and \fIs2\fR are identical.
.TP
\fIs1 \fB!\(eq\fI s2\fR
true if strings \fIs1\fR and \fIs2\fR are \fInot\fR identical.
.TP
\fIs1\fR
true if \fIs1\fR is \fInot\fR the null string.
.TP
\fIn1 \fB-eq \fIn2\fR
true if the integers \fIn1\fR and \fIn2\fR are algebraically equal. Any of
the comparisons \fB-ne\fR, \fB-gt\fR, \fB-ge\fR, \fB-lt\fR, and \fB-le\fR
may be used in place of \fBR-eq\fR.
.PP
These primaries may be combined with the following operators:
.TP 12
\fB!\fR
unary negation operator.
.TP
\fB-a\fR
binary \fIand\fR operator.
.TP
\fB-o\fR
binary \fIor\fR operator (\fB-a\fR has higher precedence than \fB-o\fR).
.TP
\fB(\fR expr \fB)\fR
parentheses for grouping.
.PP
Notice that all the operators and flags are separate arguments to \fBtest\fR.
Notice also that parentheses are meaningful to the shell and, therefore,
must be escaped.
.RE
.TP
\fBtrap\fR \*(OK \fIarg\fR \*(CK \*(OK \fIn\fR \*(CK ...
The command \fIarg\fR is to be read and executed when the shell receives
signal(s) \fIn\fR. (Note that \fIarg\fR is scanned once when the trap is set
and once when the trap is taken.) Trap commands are executed in order of
signal number. Any attempt to set a trap on a signal that was ignored on
entry to the current shell is ineffective. An attempt to trap on signal 11
(memory fault) produces an error. If \fIarg\fR is absent all trap(s) \fIn\fR
are reset to their original values. If \fIarg\fR is the null string this
signal is ignored by the shell and by the commands it invokes. If \fIn\fR is
0 the command \fIarg\fR is executed on exit from the shell. The \fBtrap\fR
command with no arguments prints a list of commands associated with each
signal number.
.TP
\fBtype\fR \*(OK \fIname\fR ... \*(CK
For each \fIname\fR, indicate how it would be interpreted if used as a command
name.
.TP
\fBumask\fR \*(OK \fInnn\fR \*(CK
The user file-creation mask is set to \fInnn\fR (see \fIumask\fR(2)). If
\fInnn\fR is omitted, the current value of the mask is printed.
.TP
\fBunset\fR \*(OK \fIname\fR ... \*(CK
For each \fIname\fR, remove the corresponding variable or function. The
variables \fB\s-1PATH\s+1\fR, \fB\s-1PS1\s+1\fR, \fB\s-1PS2\s+1\fR, and
\fB\s-1IFS\s+1\fR cannot be unset.
.TP
\fBver\fR
Display the current version of the shell.
.PD
.PP
.SS Invocation
If the shell is invoked through \fIexec\fR(2) and the first character of
argument zero is \fB-\fR or the \fB-0\fR(zero) switch is in the invokation line,
commands are initially read from \fB/etc/profile.sh\fR and from
\fB\s-1$HOME\s+1/profile.sh\fR, if such files exist. Thereafter, commands are
read as described below, which is also the case when the shell is invoked as
\fB/bin/sh\fR. The flags below are interpreted by the shell on invocation only;
Note that unless the \fB-c\fR or \fB-s\fR flag is specified, the first argument
is assumed to be the name of a file containing commands, and the remaining
arguments are passed as positional parameters to that command file:
.PP
.PD 0
.TP 10
\fB-c\fR string
If the \fB-c\fR flag is present commands are read from \fIstring\fR.
.TP
\fB-s\fR
If the \fB-s\fR flag is present or if no arguments remain commands are read
from the standard input. Any remaining arguments specify the positional
parameters. Shell output (except for \fISpecial Commands\fR) is written to
file descriptor 2.
.TP
\fB-i\fR
If the \fB-i\fR flag is present or if the shell input and output are attached
to a terminal, this shell is \fIinteractive\fR. In this case, the
\s-1TERMINATE\s+1 signal is ignored and the \s-1INTERRUPT\s+1 signal is caught
and ignored. In all cases, the \s-1QUIT\s+1 signal is ignored by the shell.
.TP
\fB-r\fR
If the \fB-r\fR flag is present, the shell is a restricted shell.
.TP
\fB-0\fR(zero)
If the \fB-0\fR(zero) flag is present, this has the same effect as starting the
shell with the first character of argument zero as a \fB-\fR (see above).
.PD
.PP
The remaining flags and arguments are described under the \fBset\fR command
above.
.SS Rsh Only
\fIRsh\fR is used to set up login names and execution environments whose
capabilities are more controlled than those of the standard shell. The
actions of \fIrsh\fR are identical to those of \fIsh\fR, except that the
following are disallowed:
.RS
.PD 0
.PP
changing directory (see \fIcd\fR(1)),
.br
setting the value of \fB$PATH\fR
.br
specifying path or command names containing \fB/\fR,
.br
redirecting output (\fB>\fR and \fB>>\fR).
.PD
.RE
.PP
The restrictions above are enforced after \fBprofile.sh\fR is interpreted.
.PP
When a command to be executed is found to be a shell procedure, \fIrsh\fR
invokes \fIsh\fR to execute it. Thus, it is possible to provide to the
end-user shell procedures that have access to the full power of the standard
shell, while imposing a limited menu of commands; this scheme assumes that the
end-user does not have write and execute permissions in the same directory.
.PP
The net effect of these rules is that the writer of the \fBprofile.sh\fR has
complete control over user actions, by performing guaranteed setup actions
and leaving the user in an appropriate directory (probably \fInot\fR the login
directory).
.PP
The system administrator often sets up a directory of commands (i.e.,
\fB/usr/rbin\fR) that can be safely invoked by \fIrsh\fR. Some systems also
provide a restricted editor \fIred\fR.
.SH EXIT STATUS
Errors detected by the shell, such as syntax errors, cause the shell to return
a non-zero exit status. If the shell is being used non-interactively execution
of the shell file is abandoned. Otherwise, the shell returns the exit status of
the last command executed (see also the \fBexit\fR command above).
.SH FILES
/etc/profile.sh
.br
\s-1$HOME\s+1/profile.sh
.br
\s-1$TMP\s+1/sh\(**
.br
??/sh.ini
.SH CRITICAL ERRORS
The Shell provide a Critical Error Handler (Interrupt 24) similar to the
standard MSDOS handler. In addition to the standard message, the handler
also displays the Extended Error Code information in hexadecimal.
.SH LIMIITATIONS
Any TSR (Terminate Stay Resident) programs must be loaded before loading
\fISh\fR as the shell will overwrite the TSR when it reloads itself after
swapping out.
.SH SEE ALSO
cd(1),
env(1),
test(1),
umask(1).
.br
dup(2),
exec(2),
pipe(2),
signal(2),
umask(2),
wait(2),
strtol(3),
profile(4),
environ(5) in the
\fI\s-1UNIX\s+1 System Programmer Reference Manual\fR.


  3 Responses to “Category : File Managers
Archive   : MS_SH164.ZIP
Filename : SH.1

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/