9.0;sh (shell), revision 9.0, 85/03/25
SH (SHELL) -- Invoke a Shell (command line interpreter).
usage: SH [pathname [arg ...]] (or) SH [
[-B[ON] | -BOFF | -NB[ON]]
[-E[ON] | -EOFF | -NE[ON]]
[-V[ON] | -VOFF | -NV[ON]]
[-X[ON] | -XOFF | -NX[ON]]
[ [ -F[IRST] ] -C[OMMAND] arg1... ]
[-I[NTER] | -S[CRIPT] | -NI[NTER]]
[-N[EXECUTE | -EX[ECUTE]]
[-P[ROMPT]1 prompt_string]
[-P[ROMPT]2 prompt_string]
[-START [file] | -NSTART]
[pathname [arg ...]] ]
FORMAT
SH [options] [pathname [arg ...]]
SH is the command line interpreter. It reads lines from standard input or
from shell programs; interprets them, finding the commands to which they refer
and the arguments for the commands; and then invokes the commands. Note that
SH does NOT create a process; it is only a program that runs inside a
pre-existing process. To start a process (which may then run a Shell or any
other program), see HELP CP.
ARGUMENTS
pathname
(optional) Specify file containing a Shell script to be executed. Each
line in the file will be interpreted as a Shell command.
Default if omitted: read standard input.
args
(optional) Specify any arguments to be passed to the program in file
'pathname'. Arguments are substituted for ^n expressions
in the program: arg1 for ^1, arg2 for ^2, etc. (See the
DOMAIN System User's Guide for details on passing arguments
to Shell commands.) See example 1 below.
Default if omitted: no arguments passed.
OPTIONS
Default options are indicated by "(D)."
-B[ON] Send the output of a background process (created with the &
parsing operator) to the display. The output of the
background process is displayed in the transcript pad of
the Shell where it was invoked. If you do not specify -B,
the output of the background process is sent to /DEV/NULL.
-BOFF (D) Do not display output from a background process.
-NB[ON] (D) Same as -BOFF.
-C[OMMAND] arg1 ...
Execute the following argument(s) as a Shell command,
exactly as if it had been read as an input line. If any
argument contains explicit blanks, enclose it in quotes.
The Shell passes all text following -C to 'arg1' as
arguments, so if you want to specify other options to the
SH command itself, they must precede -C.
-E[ON] Enable evaluation of variables outside of expressions. If
-E is specified, the Shell always evaluates variables,
regardless of the context in which they appear. If -E is
not specified, variables are evaluated only inside variable
expression delimeters, ((expression)); otherwise, the Shell
treats the ^var_name expressions as strings and they are
not evaluated.
-EOFF (D) Evaluate variables only inside expressions.
-NE[ON] (D) Same as -EOFF.
-F[IRST] Do not exit after executing the command given by the -C
option. This option is valid only if -C has been
specified, and must precede -C on the command line.
-I[NTER] Behave as though input is being entered interactively:
prompt for each input line, and do not exit on errors or
quit faults (DQ or CTRL/Q from keyboard). Normally, the
Shell only executes interactively if its input comes from a
pad or SIO line. Use of this option forces prompting.
-S[CRIPT] (D) Behave as though executing a Shell script: do not prompt
and abort on error. A Shell normally will not quit; any
error or quit command is assumed to apply only to the last
command given to the Shell.
-NI[NTER] (D) Same as -S.
-N[EXECUTE] Interpret each command line only; suppress execution.
-EX[ECUTE] (D) Interpret each command line and execute it.
-P[ROMPT]1 prompt_string
Define the prompt string for the Shell created with SH.
-P[ROMPT]2 subprompt_string
Define the subpromt string for the Shell created with SH.
(The subprompt appears when you continue a Shell command
over more than one line).
-START [file] (D)
Execute the specified script after the Shell is created.
If 'file' is not specified, the Shell searches for a file
called ~USER_DATA/SH/STARTUP and executes it if it exists.
No error occurs if that file does not exist.
-NSTART Disable startup file execution.
-V[ON] Display each line of text in the transcript pad as it is
read by the Shell program.
-VOFF (D) Disable input verification.
-NV[ON] (D) Same as -VOFF.
-X[ON] Display each command in the transcript pad immediately
before execution. Each command is given in full, with its
complete pathname and with the values of arguments
inserted.
-XOFF (D) Disable input examination.
-NX[ON] (D) Same as -XOFF.
EXAMPLES
1. $ sh program-name arg1 arg2 ... The Shell executes the commands
in the file 'program-name', and
substitutes the arguments ('argn')
for character sequences ^n in the
program file.
2. $ sh -n my_script Interpret each line in 'my_script',
but do not execute anything.
SUMMARY OF SHELL SYNTAX
cmds ->
[ pipe ] { ';' [ pipe ] | '&' [ pipe ] }
pipe ->
scmd { '|' scmd }
scmd ->
'(' cmds ')' { redir }
| 'if' scmd 'then' cmds 'else' cmds 'endif'
| 'while' scmd 'do' cmds 'enddo'
| cmd { redir | arg | '(' { arg } ')' }
redir ->
<file | >file | <?file | >?file | <<! | <<?!
cmd ->
command | shell_program
Note: everything after an unquoted, unescaped # on a line
is treated as a comment.