sh(1) DG/UX 5.4R3.00 sh(1)
NAME
sh, jsh, restsh, rsh - shell, the command programming language
SYNOPSIS
sh [ -acefhiknrstuvx ] [ args ]
jsh [ -acefhiknprstuvx ] [ args ]
restsh [ -acefhiknrstuvx ] [ args ]
rsh [ -acefhiknrstuvx ] [ args ]
DESCRIPTION
Sh is a command programming language that executes commands read from
a terminal or a file. A file of commands must have read and execute
permissions set in order for you to run it-see also umask under
"Special Commands," below. The command jsh is an interface to the
shell which provides all of the functionality of sh and enables Job
Control (see ``Job Control,'' below). Restsh is a restricted version
of the standard command interpreter sh; it sets up login names and
execution environments whose capabilities are more controlled than
those of the standard shell. Rsh may be a synonym for restsh (see
NOTES). See "Invocation," below, for the meaning of arguments to the
shell.
Sh supports editread, an optional interface used for editing command
lines entered from the shell. It also provides a history facility
that saves previously typed commands (see Using the DG/UX System for
more information).
Definitions
A blank is a tab or a space. A name is a sequence of letters,
digits, or underscores beginning with a letter or underscore. A
parameter is a name, a digit, or any of the characters *, @, #, ?, -,
$, and !.
Commands
A simple-command is a sequence of non-blank words separated by
blanks. 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 exec(2)). The value of a simple-command is its exit
status if it terminates normally, or (octal) 200+status if it
terminates abnormally (see signal(2) for a list of status values).
A pipeline is a sequence of one or more commands separated by | (or,
for historical compatibility, by ^). The standard output of each
command but the last is connected by a pipe(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.
A list is a sequence of one or more pipelines separated by ;, &, &&,
or ||, and optionally terminated by ; or &. Of these four symbols, ;
and & have equal precedence, which is lower than that of && and ||.
The symbols && and || also have equal precedence. A semicolon (;)
causes sequential execution of the preceding pipeline; an ampersand
Licensed material--property of copyright holder(s) 1
sh(1) DG/UX 5.4R3.00 sh(1)
(&) causes asynchronous execution of the preceding pipeline (i.e.,
the shell does not wait for that pipeline to finish). The symbol &&
(||) executes the list following it only if the preceding pipeline
returns a zero (non-zero) exit status. An arbitrary number of new-
lines may appear in a list, instead of semicolons, to delimit
commands.
A command 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.
for name [ in word ... ] do list done
Each time a for command is executed, name is set to the next
word taken from the in word list. If in word ... is omitted,
the for command executes the do list once for each positional
parameter that is set (see Parameter Substitution below).
Execution ends when there are no more words in the list.
case word in [ pattern [ | pattern ] ... list ;; ] ... esac
A case command executes the list associated with the first
pattern that matches word. The form of the patterns is the
same as that used for filename generation (see "Filename
Generation") except that a slash, a leading dot, or a dot
immediately following a slash need not be matched explicitly.
if list then list [ elif list then list ] ... [ else list ] fi
The list following if is executed and, if it returns a zero
exit status, the list following the first then is executed.
Otherwise, the list following elif is executed and, if its
value is zero, the list following the next then is executed.
Failing that, the else list is executed. If no else list or
then list is executed, the if command returns a zero exit
status.
while list do list done
A while command repeatedly executes the while list and, if the
exit status of the last command in the list is zero, executes
the do list; otherwise the loop terminates. If no commands in
the do list are executed, while returns a zero exit status;
use until in place of while to negate the loop termination
test.
(list)
Execute list in a sub-shell.
{list;}
list is simply executed.
name () {list;}
Define a function referenced by name. The body of the
function is the list of commands between { and }. Execution
of functions is described below (see "Execution").
Licensed material--property of copyright holder(s) 2
sh(1) DG/UX 5.4R3.00 sh(1)
The following words are recognized only when they are the first word
of a command and when they are not quoted:
if then else elif fi case esac for while until do done { }
Comments
# before a word causes that word and all the following characters up
to a new-line to be ignored.
Command Substitution
The standard output from a command enclosed in a pair of grave
accents (``) may be used as part or all of a word; trailing new-lines
are removed.
Parameter Substitution
The character $ introduces substitutable parameters. There are two
types of parameters, positional and keyword. If parameter is a
digit, it is positional. Positional parameters may be assigned
values by set. Keyword parameters (also known as variables) may be
assigned values by writing:
name=value [ name=value ] ...
Pattern-matching is not performed on value. There cannot be a
function and a variable with the same name.
${parameter}
The value, if any, of the parameter is substituted. The
braces are required only when parameter is followed by a
letter, digit, or underscore that is not to be interpreted as
part of its name. If parameter is * or @, all the positional
parameters, starting with $1, are substituted (separated by
spaces). Parameter $0 is set from argument zero when the
shell is invoked.
${parameter:-word}
If parameter is set and is non-null, substitute its value;
otherwise, substitute word.
${parameter:=word}
If parameter is not set or is null, set it to word; the value
of the parameter is substituted. Positional parameters may
not be assigned to in this way.
${parameter:?word}
If parameter is set and is non-null, substitute its value;
otherwise, print word and exit from the shell. If word is
omitted, the message "parameter null or not set" is printed.
${parameter:+word}
If parameter is set and is non-null, substitute word;
otherwise, substitute nothing.
Licensed material--property of copyright holder(s) 3
sh(1) DG/UX 5.4R3.00 sh(1)
In the above, word is not evaluated unless it is to be used as the
substituted string, so that, in the following example, pwd is
executed only if d is not set or is null:
echo ${d:-`pwd`}
If the colon (:) is omitted from the above expressions, the shell
only checks whether parameter is set.
The shell sets these parameters automatically:
# The number of positional parameters in decimal.
- Flags supplied to the shell on invocation or by the set
command.
? The decimal value returned by the last synchronously
executed command.
$ The process number of this shell.
! The process number of the last background command
invoked.
The following parameters are used by the shell:
HOME The default argument (home directory) for the cd command.
PATH The search path for commands (see "Execution," below). The
user may not change PATH if executing under restsh.
CDPATH The search path for the cd command.
MAIL If this parameter is set to the name of a mail file and the
MAILPATH parameter is not set, the shell informs the user
of the arrival of mail in the specified file.
MAILCHECK This parameter specifies how often (in seconds) the shell
will check for mail in the files specified by the MAILPATH
or MAIL parameters. The default value is 600 seconds (10
minutes). If set to 0, the shell will check before each
prompt.
MAILPATH A colon (:) separated list of filenames. If this parameter
is set, the shell informs the user of the arrival of mail
in any of the specified files. Each filename can be
followed by % and a message that will be printed when the
modification time changes. The default message is you have
mail.
PS1 Primary prompt string, by default $.
PS2 Secondary prompt string, by default >.
Licensed material--property of copyright holder(s) 4
sh(1) DG/UX 5.4R3.00 sh(1)
IFS Internal field separators, normally space, tab, and new-
line.
SHACCT If this parameter is set to the name of a file writable by
the user, the shell will write an accounting record in the
file for each shell procedure executed. Accounting
routines such as acctcom(1) and acctcms(1M) can be used to
analyze the data collected.
SHELL When the shell is invoked, it scans the environment (see
"Environment," below) for this name. If it is found and
there is an r in the filename part of its value, the shell
becomes a restricted shell.
The shell gives default values to PATH, PS1, PS2, MAILCHECK and IFS.
HOME and MAIL are set by login(1).
Blank Interpretation
After parameter and command substitution, the results of substitution
are scanned for internal field separator characters (those found in
IFS) and split into distinct arguments where such characters are
found. Explicit null arguments ("" or '') are retained. Implicit
null arguments (those resulting from parameters that have no values)
are removed.
Filename Generation
Following substitution, each command word is scanned for the
characters *, ?, and [. If one of these characters appears, the word
is regarded as a pattern. The word is replaced with alphabetically
sorted filenames that match the pattern. If no filename matches the
pattern, the word is left unchanged. The character . at the start
of a filename or immediately following a /, as well as the character
/ itself, must be matched explicitly.
* Matches any string, including the null string.
? Matches any single character.
[ ... ]
Matches any one of the enclosed characters. A pair of
characters separated by - matches any character
lexically between the pair, inclusive. If the first
character following the opening [ is a !, any character
not enclosed is matched.
Quoting
The following characters have a special meaning to the shell and
terminate a word unless quoted:
; & ( ) | ^ < > new-line space tab
You can make a character stand for itself by preceding it with a \.
This is called quoting. The pair \new-line is ignored. All
Licensed material--property of copyright holder(s) 5
sh(1) DG/UX 5.4R3.00 sh(1)
characters enclosed between a pair of single quote marks (''), except
a single quote, are quoted. Inside double quote marks (""),
parameter and command substitution occurs and \ quotes the characters
\, `, ", and $. "$*" is equivalent to "$1 $2 ...", whereas "$@" is
equivalent to "$1" "$2" ....
Prompting
When used interactively, the shell prompts with the value of PS1
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 PS2) is issued.
Input/Output
Before a command is executed, you can redirect its input and output
using a special notation interpreted by the shell. The following may
appear anywhere in a simple-command or may precede or follow a
command. They are not passed on to the invoked command; substitution
occurs before word or digit is used:
<word Use file word as standard input (file descriptor 0).
>word Use file word as standard output (file descriptor 1).
If the file does not exist, it is created; otherwise,
it is truncated to zero length.
>>word Use file word 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.
<<[-]word The shell input is read up to a line that is the same
as word, or to an end-of-file. The resulting document
becomes the standard input. If any character of word
is quoted, no interpretation is placed upon the
characters of the document; otherwise, parameter and
command substitution occurs, (unescaped) \new-line is
ignored, and \ must be used to quote the characters \,
$, `, and the first character of word. If - is
appended to <<, all leading tabs are stripped from word
and from the document.
<&digit Use the file associated with file descriptor digit as
standard input. Similarly for the standard output
using >&digit.
<&- The standard input is closed. Similarly for the
standard output using >&-.
Note that when the shell creates a file, the base mode is 666, rather
than 777. The mode is then filtered through the current umask. See
umask under "Special Commands," below, and umask(1).
If any of the above is preceded by a digit, the file descriptor
associated with the file is that specified by the digit (instead of
Licensed material--property of copyright holder(s) 6
sh(1) DG/UX 5.4R3.00 sh(1)
the default 0 or 1). For example:
... 2>&1
associates file descriptor 2 with the file currently associated with
file descriptor 1.
The order in which redirections are specified is significant. The
shell evaluates redirections from left to right. For example:
... 1>xxx 2>&1
first associates file descriptor 1 with file xxx. It then associates
file descriptor 2 with xxx. 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 xxx.
If a command is followed by &, the default standard input for the
command is the empty file /dev/null. Otherwise, the environment for
the execution of a command contains the file descriptors of the
invoking shell as modified by input/output specifications.
Redirection of output is not allowed in the restricted shell.
Environment
The environment (see environ(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 export
command is used to bind the shell's parameter to the environment (see
also set -a ). A parameter may be removed from the environment with
the unset 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 unset, plus any modifications or additions, all
of which must be noted in export commands.
You can augment the environment for any simple-command by prefixing
it with one or more assignments to parameters. Thus:
TERM=605x cmd
and
(export TERM; TERM=605x; cmd )
are equivalent (as far as the execution of cmd is concerned).
If the -k flag is set, all keyword arguments are placed in the
Licensed material--property of copyright holder(s) 7
sh(1) DG/UX 5.4R3.00 sh(1)
environment, even if they occur after the command name. The
following first prints a=b c and c:
echo a=b c
set -k
echo a=b c
Signals
The INTERRUPT and QUIT signals for an invoked command are ignored if
the command is followed by &; otherwise, signals have the values
inherited by the shell from its parent, with the exception of signal
11. See also the trap command below.
Execution
Each time a command is executed, the above substitutions are made.
If the command name matches one of the special commands listed below,
it is executed in the shell process. If the command name does not
match a special command 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
$1, $2, .... are set to the arguments of the function. If the
command name matches neither a special command nor the name of a
defined function, a new process is created and the system tries to
execute the command using exec(2).
The shell parameter PATH defines the search path for the directory
containing the command. Alternative directory names are separated by
a colon (:). The default path is :/bin:/usr/bin (specifying the
current directory, /bin, and /usr/bin, in that order). Note that the
current directory is specified by a null pathname, which can appear
immediately after the equal sign or between the colon delimiters
anywhere else in the path list.
If the command name contains a /, 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. If
the file has execute permission but is not an executable program
(binary) file, it is assumed to be a file containing shell commands.
A sub-shell is spawned to read it. A parenthesized command is also
executed in a sub-shell.
The shell remembers a command's location in the search path (to avoid
having to search through your path again should you invoke the
command again later). If the command was found in a relative
directory, however, its location must be re-determined whenever the
current directory changes. The shell forgets all remembered
locations whenever the PATH variable is changed or the hash -r
command is executed (see below).
Special Commands
Input/output redirection is now permitted for these commands. File
descriptor 1 is the default output location.
Licensed material--property of copyright holder(s) 8
sh(1) DG/UX 5.4R3.00 sh(1)
: No effect; the command does nothing. A zero exit code is
returned.
. file Read and execute commands from file and return. The search
path specified by PATH finds the directory containing file.
You must have read and execute permission for the file.
break [ n ]
Exit from the enclosing for or while loop, if any. If n is
specified, break n levels.
continue [ n ]
Resume the next iteration of the enclosing for or while loop.
If n is specified, resume at the nth enclosing loop.
cd [ arg ]
Change the current directory to arg. The shell parameter HOME
is the default arg. The shell parameter CDPATH defines the
search path for the directory containing arg. Alternative
directory names are separated by a colon (:). The default
path is null (specifying the current directory). Note that
the current directory is specified by a null pathname, which
can appear immediately after the equal sign or between the
colon delimiters anywhere else in the path list. If arg
begins with a /, the search path is not used; otherwise, each
directory in the path is searched for arg. The cd command may
not be executed by restsh.
echo [ arg ... ]
Echo arguments. See echo(1) for usage and description.
eval [ arg ... ]
The arguments are read as input to the shell and the resulting
command(s) executed.
exec [ arg ... ]
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.
exit [ n ]
Causes a shell to exit with the exit status specified by n.
If n is omitted, the exit status is that of the last command
executed. An end-of-file will also cause the shell to exit.
export [ name ... ]
The given names are marked for automatic export to the
environment 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 not be exported.
hash [ -r ] [ name ... ]
This option is available in DG/UX only. The shell finds and
Licensed material--property of copyright holder(s) 9
sh(1) DG/UX 5.4R3.00 sh(1)
remembers the location in the search path of each command
specified by name. The -r option makes the shell forget all
remembered locations. If no arguments are given, information
about remembered commands is presented. Hits is the number of
times a command has been invoked by the shell process. Cost
is a measure of the work required to locate a command in the
search path. Some situations require that the stored location
of a command be recalculated. These commands are indicated by
an asterisk (*) adjacent to the hits information. Cost is
incremented when the recalculation is done.
newgrp [ arg ... ]
Equivalent to exec newgrp arg .... See newgrp(1) .
pwd Print the current working directory. This is a sh built-in
command that is not the same as the /bin/pwd command discussed
in the pwd(1) manual page. The /bin/pwd program exists for
the csh--it does not have a built-in pwd command.
read [ name ... ]
One line is read from the standard input and the first word is
assigned to the first name, the second word to the second
name, etc., with leftover words assigned to the last name.
The return code is 0 unless an end-of-file is encountered.
readonly [ name ... ]
The given names are marked readonly and the values of these
names may not be changed by subsequent assignment. If no
arguments are given, a list of all readonly names is printed.
return [ n ]
Causes a function to exit with the return value specified by
n. If n is omitted, the return status is that of the last
command executed.
set [ --aefhkntuvx [ arg ... ] ]
-a Mark variables that are modified or created for export.
-e Exit immediately if a command exits with a non-zero
exit status.
-f Disable filename generation.
-h Find and remember function commands as functions are
defined (function commands are normally located when
the function is executed).
-k All keyword arguments are placed in the environment for
a command, not just those that precede the command
name.
-n Read commands but do not execute them.
Licensed material--property of copyright holder(s) 10
sh(1) DG/UX 5.4R3.00 sh(1)
-t Exit after reading and executing one command.
-u Treat unset variables as an error when substituting.
-v Print shell input lines as they are read.
-x Print commands and their arguments as they are
executed.
-- Do not change any of the flags; useful in setting $1 to
-.
Using + rather than - turns these flags off. These flags can
also be used upon invocation of the shell. The current
setting of flags may be found in $-. The remaining arguments
are positional parameters and are assigned, in order, to $1,
$2, .... If no arguments are given, the values of all names
are printed.
shift [ n ]
The positional parameters from $n+1 ... are renamed $1 ....
If n is not given, it is assumed to be 1.
test
Evaluate conditional expressions. See test(1) for usage and
description.
times
Print the accumulated user and system times for processes run
from the shell.
trap [ arg ] [ n ] ...
Read and execute the command arg when the shell receives
signal(s) n. (Note that arg 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)
or signal 18 (termination of child process) produces an error.
If arg is absent, all trap(s) n are reset to their original
values. If arg is the null string, this signal is ignored by
the shell and by the commands it invokes. If n is 0, the
command arg is executed on exit from the shell. The trap
command with no arguments prints a list of commands associated
with each signal number.
type [ name ... ]
For each name, indicate how it would be interpreted if used as
a command name.
ulimit [ -[HS][a | cdfnstv]]
ulimit [ -[HS][c | d | f | n | s | t | v] ] limit
ulimit prints or sets hard or soft resource limits. These
Licensed material--property of copyright holder(s) 11
sh(1) DG/UX 5.4R3.00 sh(1)
limits are described in getrlimit(2).
If limit is not present, ulimit prints the specified limits.
Any number of limits may be printed at one time. The -a
option prints all limits.
If limit is present, ulimit sets the specified limit to limit.
The string unlimited requests the largest valid limit. Limits
may be set for only one resource at a time. Any user may set
a soft limit to any value below the hard limit. Any user may
lower a hard limit. Only a super-user may raise a hard limit;
see su(1).
The -H option specifies a hard limit. The -S option specifies
a soft limit. If neither option is specified, ulimit will set
both limits and print the soft limit.
The following options specify the resource whose limits are to
be printed or set. If no option is specified, the file size
limit is printed or set.
-c maximum core file size (in 512-byte blocks)
-d maximum size of data segment or heap (in
kbytes)
-f maximum file size (in 512-byte blocks)
-n maximum file descriptor plus 1
-s maximum size of stack segment (in kbytes)
-t maximum CPU time (in seconds)
-v maximum size of virtual memory (in kbytes)
umask [ nnn ]
The user file-creation mask is set to nnn (see umask(2)). If
nnn is omitted, the current value of the mask is printed.
Note that the shell and any programs running under the shell,
like ed(1), create files with a maximum permission of 666,
even if you set the mask to 000. The mask value is subtracted
from 777 to arrive at the final mode, however. A mask of 012
yields a mode of 665, for example. You must use chmod to add
the execution permission. This is especially important if you
are creating a shell program, since it must have read and
execute permissions in order to run.
wait [ n ]
Wait for the specified process and report its termination
status. If n is not given, all currently active child
processes are waited for and the return code is zero.
Licensed material--property of copyright holder(s) 12
sh(1) DG/UX 5.4R3.00 sh(1)
Invocation
If the shell is invoked through exec(2) and the first character of
argument zero is -, commands are initially read from /etc/profile and
from $HOME/.profile, if such files exist. Thereafter, commands are
read as described below, which is also the case when the shell is
invoked as /bin/sh. The flags below are interpreted by the shell on
invocation only. Unless the -c or -s 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:
-c string Commands are read from string.
-s If no arguments remain, commands are read from the
standard input. Any remaining arguments specify the
positional parameters. Shell output (except for Special
Commands) is written to file descriptor 2.
-i If the shell input and output are attached to a
terminal, this shell is interactive. In this case
TERMINATE is ignored (so that kill 0 does not kill an
interactive shell) and INTERRUPT is caught and ignored
(so that wait is interruptible). In all cases, QUIT is
ignored by the shell.
-r The shell is a restricted shell.
The remaining flags and arguments are described under the set command
above.
Job Control (jsh)
When the shell is invoked as jsh, Job Control is enabled in addition
to all of the functionality described previously for sh. Typically
Job Control is enabled for the interactive shell only. Non-
interactive shells typically do not benefit from the added
functionality of Job Control.
With Job Control enabled every command or pipeline the user enters at
the terminal is called a job. All jobs exist in one of the following
states: foreground, background or stopped. These terms are defined
as follows: 1) a job in the foreground has read and write access to
the controlling terminal; 2) a job in the background is denied read
access and has conditional write access to the controlling terminal
[see stty(1)]; 3) a stopped job is a job that has been placed in a
suspended state, usually as a result of a SIGTSTP signal [see
signal(5)].
Every job that the shell starts is assigned a positive integer,
called a job number which is tracked by the shell and will be used as
an identifier to indicate a specific job. Additionally the shell
keeps track of the current and previous jobs. The current job is the
most recent job to be started or restarted. The previous job is
Licensed material--property of copyright holder(s) 13
sh(1) DG/UX 5.4R3.00 sh(1)
the first non-current job.
The acceptable syntax for a Job Identifier is of the form:
%jobid
where, jobid may be specified in any of the following formats:
% or + for the current job
- for the previous job
?string specify the job for which the command line uniquely
contains string.
n for job number n, where n is a job number
pref where pref is a unique prefix of the command name
(for example, if the command ls -l foo were running
in the background, it could be referred to as %ls);
pref cannot contain blanks unless it is quoted.
When Job Control is enabled, the following commands are added to the
user's environment to manipulate jobs:
bg [%jobid ...]
Resumes the execution of a stopped job in the background. If
%jobid is omitted the current job is assumed.
fg [%jobid ...]
Resumes the execution of a stopped job in the foreground, also
moves an executing background job into the foreground. If
%jobid is omitted the current job is assumed.
jobs [-p|-l] [%jobid ...]
jobs -x command [arguments]
Reports all jobs that are stopped or executing in the
background. If %jobid is omitted, all jobs that are stopped
or running in the background will be reported. The following
options will modify/enhance the output of jobs:
-l Report the process group ID and working directory of
the jobs.
-p Report only the process group ID of the jobs.
-x Replace any jobid found in command or arguments with
the corresponding process group ID, and then execute
command passing it arguments.
kill [-signal] %jobid
Builtin version of kill to provide the functionality of the
kill command for processes identified with a jobid.
Licensed material--property of copyright holder(s) 14
sh(1) DG/UX 5.4R3.00 sh(1)
stop %jobid ...
Stops the execution of a background job(s).
suspend
Stops the execution of the current shell (but not if it is the
login shell).
wait [%jobid ...]
wait builtin accepts a job identifier. If %jobid is omitted
wait behaves as described above under Special Commands.
Restsh Only
Restsh sets up login names and execution environments that are more
controlled than those of the standard shell. Restsh is identical to
sh, except that the following are disallowed:
changing directory (see cd(1))
setting the value of $PATH and $SHELL
specifying command names containing /
redirecting output (> and >>)
The restrictions above are enforced after .profile is interpreted.
When a command to be executed is a shell procedure, restsh invokes sh
to execute it. Thus, you can give procedures to the end-user shell
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.
The net effect of these rules is to give the writer of the .profile
complete control over user actions, by performing guaranteed setup
actions and leaving the user in an appropriate directory (probably
not the login directory).
The system administrator often sets up a directory of commands (i.e.,
/usr/rbin) that can be safely invoked by restsh. Some systems also
provide a restricted editor red.
EXIT CODES
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 except under
special conditions:
The "echo" and "pwd" built-in commands have counterparts in
the /bin directory. If you use /bin/echo or /bin/pwd in a
shell script rather than the built-in echo or bin, execution
of the script will continue after an error.
Otherwise, the shell returns the exit status of the last command
executed (see also the exit command above).
Licensed material--property of copyright holder(s) 15
sh(1) DG/UX 5.4R3.00 sh(1)
jsh Only
If the shell is invoked as jsh and an attempt is made to exit the
shell while there are stopped jobs, the shell issues one warning:
There are stopped jobs.
This is the only message. If another exit attempt is made, and there
are still stopped jobs they will be sent a SIGHUP signal from the
kernel and the shell is exited.
FILES
/etc/profile
$HOME/.profile
/tmp/sh*
/dev/null
SEE ALSO
acctcom(1), cd(1), echo(1), env(1), login(1), newgrp(1), test(1),
umask(1).
acctcms(1M)
dup(2), exec(2), fork(2), pipe(2), signal(2), ulimit(2), umask(2),
wait(2), a.out(4), profile(4), environ(5)
See Using the DG/UX System for complete information on using the
Bourne shell.
NOTES
If a command is executed and a command with the same name is
installed in a directory in the search path before the directory
where the original command was found, the shell continues to execute
(with exec) the original command. Use the hash command to correct
this situation.
If you move the current directory or one above it, pwd may not give
the correct response. Use the cd command with a full pathname to
correct this situation.
If /usr/ucb (a link to /usr/bin) is found on the path before
/usr/bin, the behavior of the built in commands echo and test change
to act like a BSD system.
When TCP/IP is installed on the system, rsh is equivalent to
remsh(1C). Otherwise, rsh is identical to restsh.
When the user places a command in the background, the sh sets the
signal handlers for SIGINT and SIGQUIT to SIGIGN. This prevents
these signals from interrupting background tasks. However, since the
background task is still in the same process group as the parent, the
SIGINT and SIGQUIT signals are still delivered. This means that if
the background process installs its own signal handler, it will
receive these signals. This can cause background tasks to be
terminated by control-c's from the foreground sh. The work around
for this is to invoke the sh as jsh (see above), or use the csh(1) or
ksh(1) commands. This functionality is required by Posix 1003.2
Licensed material--property of copyright holder(s) 16
sh(1) DG/UX 5.4R3.00 sh(1)
section 3.11.
Licensed material--property of copyright holder(s) 17