Format
set [±abCefhiKkLmnPpstuvx–]
[±o[flag]] [±Aname][parameter
…]
tcsh shell:
set [-r]. set [-r] name ....
set [-r] name=word ....
set [-r] [-f|-l] name=(wordlist) ....
set name[index]=word ...
Description
Calling
set without
arguments displays the names and values of all shell variables, sorted
by name, in the following format:
Variable="value"
The
quoting allows the output to be reinput to the shell using the built-in
command
eval. Arguments of the form
–option set
each shell flag specified as an option. Similarly, arguments of the
form
+option turn
off each of the shell flags specified as an option. (Contrary to what
you might expect,
– means
on, and
+ means
off.)
Note: All of the set options except ±A, –s, –,
and –– are shell flags. Shell flags can
also be set on the sh command line at invocation.
In the tcsh shell
See the Format section to
view the following forms:
- The first form of the command prints the value of all shell variables.
Variables which contain more than a single word print as a parenthesized
word list.
Variables that are read-only will only be displayed
by using the -r option. For forms 2, 3
and 4, if -r is specified, the value is
set to read-only.
- The second form sets name to the null
string.
- The third form sets name to the single word.
- The fourth form sets name to the list
of words in wordlist. In all cases the value
is command and file name expanded. If -f or -l is
specified, set only unique words keeping
their order. -f prefers the first occurrence
of a word, and -l the last.
- The fifth form sets the index'th component
of name to word;
this component must already exist.
These arguments can be repeated to either set or make read-only
multiple variables in a single set command. However, variable expansion
happens for all arguments before any setting occurs. Also, = can be
next to both name and word or separated from both by white space,
but cannot be next to only one or the other. For example:
set -r name=word and set -r name = word
are
allowed, but
set -r name= word and set -r name =word
are
not allowed.
For more information, see tcsh — Invoke a C shell.
Options
- –a
- Sets all subsequently defined variables for export.
- –b
- Notifies you when background jobs finish running.
- –C
- Prevents the output redirection operator > from
overwriting an existing file. Use the alternate operator >| to
force an overwrite.
- –e
- Tells a noninteractive shell to execute the ERR trap and then
exit. This flag is disabled when reading profiles.
- –f
- Disables path name generation.
- –h
- Makes all commands use tracked aliases. (For an explanation of
tracked aliases, see the Command execution section
in sh.
- –i
- Makes the shell interactive.
- –K
- Tells the shell to use Korn Shell compatible support of the ((expression))
syntax for arithmetic expressions and trap behavior within shell
functions. Korn Shell behavior might conflict with UNIX standard-conforming
behavior. For more details, see the let and trap command
descriptions.
- –k
- Allows assignment parameters anywhere on the command line and
still includes them in the environment of the command.
- –L
- Makes the shell a login shell. Setting this flag is effective
only at shell invocation.
- –m
- Runs each background job in a separate process group and reports
on each as they complete.
- –n
- Tells a noninteractive shell to read commands but not run them.
- –o flag
- Sets a shell flag. If you do not specify flag,
this option lists all shell flags that are currently set. flag can
be one of the following:
- allexport
- Is the same as the –a option.
- errexit
- Is the same as the –e option.
- bgnice
- Runs background jobs at a lower priority.
- emacs
- Specifies emacs- style inline editor
for command entry. See shedit for information
about the emacs editing mode.
- gmacs
- Specifies gmacs- style inline editor
for command entry. See shedit for
information about the gmacs editing mode.
- ignoreeof
- Tells the shell not to exit when an end-of-file character is entered.
- interactive
- Is the same as the –i option.
- keyword
- Is the same as the –k option.
- korn
- Is the same as the –K option.
- logical
- Specifies that cd, pwd,
and the PWD variable use logical path names in directories with symbolic
links. If this flag is not set, these built-ins and PWD use physical
directory path names. For example, assume /usr/spool is a symbolic
link to /var/spool, and that it is your current directory.
If logical is not set, PWD has the value /var/spool,
and cd changes the current directory to /var.
If logical is set, PWD has the value /usr/spool and cd changes
the current directory to /usr.
- login
- Is the same as the –L option of sh.
- markdirs
- Adds a trailing slash (/) to filename-generated
directories.
- monitor
- Is the same as the –m option.
- noclobber
- Is the same as the –C option.
- noexec
- Is the same as the –n option.
- noglob
- Is the same as the –f option.
- nolog
- Does not record function definitions in the history file.
- notify
- Is the same as the –b option.
- nounset
- Is the same as the –u option.
- pipecurrent
- Is the same as the –P option.
- privileged
- Is the same as the –p option.
- trackall
- Is the same as the –h option.
- verbose
- Is the same as the –v option.
- xtrace
- Is the same as the –x option.
- vi
- Specifies vi- style inline editor. See shedit for
information about the vi editing mode.
- warnstopped
- Tells the shell to issue a warning, but not to exit, when there
are stopped jobs.
- –p
- Disables the processing of $HOME/.profile for a login
shell and disables the processing of the script specified by the ENV
variable. If /etc/suid_profile exists, sh runs
it instead of the ENV script.
- –P
- Runs the last command of a pipeline in the current shell environment.
- –s
- Sorts the positional parameters.
- –t
- Exits after reading and running one command.
- –u
- Tells the shell to issue an error message if an unset parameter
is used in a substitution.
- –v
- Prints shell input lines as they are read.
- –x
- Prints commands and their arguments as they run.
Other options:
- –
- Turns off the –v and –x options.
Also, parameters that follow this option do not set shell flags, but
are assigned to positional parameters (see sh).
- ––
- Specifies that parameters following this option do not set shell
flags, but are assigned to positional parameters.
- +A name
- Assigns the parameter list specified on the command line to the
array elements of the variable name, starting
at name[0]. For example,
the following command assigns the values "a", "b", "c" and "d" to
the array elements array[0-3]:
set +A array a b c d
echo ${array[*]}
a b c d
- –A name
- Unsets the variable name and then assigns
the parameter list specified on the command line to the array elements
of the variable name starting at name[0].
For example, if the variable array contains 4 elements, the following
command discards the previous values and assigns the values "x" and
"y" to the array elements array[0-1]:
set -A array a y
echo ${array[*]}
x y
Usage notes
set is
a special built-in shell command.
Localization
set uses
the following localization environment variables:
- LANG
- LC_ALL
- LC_MESSAGES
- NLSPATH
For more information, see Localization.
Exit values
- 0
- Successful completion
- 1
- Failure due to an incorrect command-line argument
- 2
- Failure resulting in a usage message, usually due to a missing
argument
Portability
Several shell flags are extensions
of the POSIX standard: bgnice, ignoreeof, keyword, markdirs, monitor, noglob, nolog, privileged,
and trackall are extensions of the POSIX
standard, along with the shell flags ±A, ±h, ±k, ±p, ±s,
and ±t.
Related information
alias, eval, export, sh, shedit, tcsh, trap, typeset