SET(1SH) COMMAND REFERENCE SET(1SH)
NAME
set - set shell options and parameters (sh built-in)
SYNOPSIS
set - [ -, a, e, f, h, k, n, t, u, v, x ][ arg . . . ]
DESCRIPTION
Set is used to set options and reset positional parameters.
If the first argument begins with a dash (-) or a plus sign
(+), it is interpreted as options to the shell. A leading
dash (-) turns the option on, and a plus sign (+) turns the
option off.
All remaining arguments are positional parameters and are
assigned, in order, to $1, $2, and so forth. The lone dash
(-) is not assigned.
If no arguments are given, the values of all shell
variables, except for those set internally, are printed.
The options for set can also be used upon invocation of the
shell. The current set of options may be found in $-.
OPTIONS
-- Null option. Useful for setting positional parameters
when the first parameter begins with a dash (-).
The following options are shown with a leading dash (-),
which can be replaced by a plus sign (+) for the reverse
effect:
-a Mark variables which are modified or created for export
to the environment.
-e If noninteractive, exit immediatly if a command fails.
-f Disable filename generation.
-h Locate and remember commands in functions as functions
are defined. Normally, function commands are located
when the function is executed.
-k All keyword parameters are placed in the environment for
a command, not just those that precede the command name.
-n Read commands but do not execute them.
-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.
Printed 4/6/89 1
SET(1SH) COMMAND REFERENCE SET(1SH)
-x Print commands and their arguments as they are executed.
EXAMPLES
The following command sets the -x and -e options in the
current shell:
set -xe
The following shell script prints the name and size of all
files in the current directory not owned by the user
specified on the command line. The default user is the user
that invokes the script.
#!/bin/sh
Userid=${1-`whoami`}
for i in .* *
{
set - `ll -d "$i"`
if test "$Userid" != "$3"
then
echo "$i\t\t$4"
fi
}
RETURN VALUE
[NO_ERRS] Command completed without error.
[USAGE] Incorrect command line syntax. Execution
terminated.
CAVEATS
It is not possible to set and unset options in the same
invocation of set.
SEE ALSO
break(1sh), cd(1sh), chdir(1sh), continue(1sh), csh(1csh),
echo(1sh), eval(1sh), exec(1sh), exit(1sh), export(1sh),
getopt(1), hash(1sh), login(1), pwd(1sh), read(1sh),
readonly(1sh), return(1sh), sh(1sh), shift(1sh), test(1sh),
times(1sh), trap(1sh), type(1sh), ulimit(1sh), umask(1sh),
unset(1sh), wait(1sh), which(1sh), and execve(2).
Printed 4/6/89 2
%%index%%
na:264,108;
sy:372,307;
de:679,859;
op:1538,1242;3116,86;
ex:3202,697;
rv:3899,271;
ca:4170,194;
se:4364,894;
%%index%%000000000143