2 .\" Copyright (c) 2007 Sun Microsystems, Inc. All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
6 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
7 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
8 .TH SET 1 "Nov 20, 2007"
10 set, unset, setenv, unsetenv, export \- shell built-in functions to determine
11 the characteristics for environmental variables of the current shell and its
17 \fBset\fR [\fB--aefhkntuvx\fR [\fIargument\fR]]...
22 \fBunset\fR [\fIname\fR]...
27 \fBexport\fR [\fIname\fR]...
33 \fBset\fR [\fIvar\fR [= \fIvalue\fR]]
38 \fBset\fR \fIvar\fR [\fIn\fR] = \fIword\fR
43 \fBunset\fR \fIpattern\fR
48 \fBsetenv\fR [\fIVAR\fR [\fIword\fR]]
53 \fBunsetenv\fR \fIvariable\fR
59 \fBset\fR [\(+-abCefhkmnopstuvx] [\(+-o \fIoption\fR]... [\(+-A \fIname\fR]
65 \fBunset\fR [\fB-f\fR] \fIname\fR...
70 \fB**export\fR [\fIname\fR [=\fIvalue\fR]]...
75 \fB**export\fR [\fB-p\fR]
81 \fB+set\fR [\(+-abCefGhkmnoprstuvx] [\(+-o \fIoption\fR]... [\(+-A \fIvname\fR]
87 \fB+unset\fR [\fB-fnv\fR] \fIvname\fR...
92 \fB++export\fR [\fB-p\fR] [\fIname\fR[=\fIvalue\fR]]...
98 The \fBset\fR built-in command has the following options:
105 Does not change any of the flags. This option is useful in setting \fB$1\fR to
115 Marks variables which are modified or created for export.
124 Exits immediately if a command exits with a non-zero exit status.
133 Disables file name generation.
142 Locates and remembers function commands as functions are defined. Function
143 commands are normally located when the function is executed.
152 All keyword arguments are placed in the environment for a command, not just
153 those that precede the command name.
162 Reads commands but does not execute them.
171 Exits after reading and executing one command.
180 Treats unset variables as an error when substituting.
189 Prints shell input lines as they are read.
198 Prints commands and their arguments as they are executed.
203 Using \fB+\fR rather than \fB\(mi\fR causes these flags to be turned off. These
204 flags can also be used upon invocation of the shell. The current set of flags
205 can be found in \fB$\(mi\fR. The remaining \fIargument\fRs are positional
206 parameters and are assigned, in order, to \fB$1\fR, \fB$2\fR,
207 \fB\&.\|.\|.\|.\fR If no \fIargument\fRs are specified the values of all names
211 For each \fIname\fR, \fBunset\fR removes the corresponding variable or function
212 value. The variables \fBPATH\fR, \fBPS1\fR, \fBPS2\fR, \fBMAILCHECK\fR, and
213 \fBIF\fR cannot be unset.
216 With the \fBexport\fR built-in, the specified \fIname\fRs are marked for
217 automatic export to the \fIenvironment\fR of subsequently executed commands. If
218 no arguments are specified, variable names that have been marked for export
219 during the current shell's execution are listed. Function names are \fBnot\fR
223 With no arguments, \fBset\fR displays the values of all shell variables.
224 Multiword values are displayed as a parenthesized list. With the \fIvar\fR
225 argument alone, \fBset\fR assigns an empty (null) value to the variable
226 \fIvar\fR. With arguments of the form \fIvar\fR \fB=\fR \fIvalue\fR \fBset\fR
227 assigns \fIvalue\fR to \fIvar\fR, where \fIvalue\fR is one of:
234 A single word (or quoted string).
240 \fB\fB(\fR\fIwordlist\fR\fB)\fR\fR
243 A space-separated list of words enclosed in parentheses.
248 Values are command and filename expanded before being assigned. The form
249 \fBset\fR \fIvar\fR\fB[\fR\fIn\fR\fB]=\fR\fIword\fR replaces the \fIn\fR'th
250 word in a multiword value with \fIword\fR.
253 \fBunset\fR removes variables whose names match (filename substitution)
254 \fIpattern\fR. All variables are removed by `\fBunset *\fR'.
257 With no arguments, \fBsetenv\fR displays all environment variables. With the
258 \fIVAR\fR argument, \fBsetenv\fR sets the environment variable
259 \fB\fR\fIVAR\fR\fB \fR to an empty (null) value. (By convention, environment
260 variables are normally specified upper-case names.) With both \fIVAR\fR and
261 \fIword\fR arguments specified, \fBsetenv\fR sets \fIVAR\fR to \fIword\fR,
262 which must be either a single word or a quoted string. The \fBPATH\fR variable
263 can take multiple \fIword\fR arguments, separated by colons (see EXAMPLES). The
264 most commonly used environment variables, \fBUSER\fR, \fBTERM\fR, and
265 \fBPATH\fR, are automatically imported to and exported from the \fBcsh\fR
266 variables \fBuser\fR, \fBterm\fR, and \fBpath\fR. Use \fBsetenv\fR if you need
267 to change these variables. In addition, the shell sets the \fBPWD\fR
268 environment variable from the \fBcsh\fR variable \fBcwd\fR whenever the latter
272 The environment variables \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_TIME\fR,
273 \fBLC_COLLATE\fR, \fBLC_NUMERIC\fR, and \fBLC_MONETARY\fR take immediate effect
274 when changed within the C shell. See \fBenviron\fR(5) for descriptions of these
275 environment variables.
278 \fBunsetenv\fR removes \fIvariable\fR from the environment. As with
279 \fBunset\fR, pattern matching is not performed.
282 The flags for the \fBset\fR built-in have meaning as follows:
289 Array assignment. Unsets the variable \fIname\fR and assigns values
290 sequentially from the list \fIarg\fR. If \fB+A\fR is used, the variable
291 \fIname\fR is not unset first.
300 All subsequent variables that are defined are automatically exported.
309 Causes the shell to notify the user asynchronously of background job
319 Prevents existing files from being overwritten by the shell's \fB>\fR
320 redirection operator. The \fB>|\fR redirection operator overrides this
321 noclobber option for an individual file.
330 If a command has a non-zero exit status, executes the \fBERR\fR trap, if set,
331 and exits. This mode is disabled while reading profiles.
340 Disables file name generation.
349 Each command becomes a tracked alias when first encountered.
358 All variable assignment arguments are placed in the environment for a command,
359 not just those that precede the command name.
368 Background jobs run in a separate process group and a line prints upon
369 completion. The exit status of background jobs is reported in a completion
370 message. On systems with job control, this flag is turned on automatically for
380 Reads commands and checks them for syntax errors, but does not execute them.
381 Ignored for interactive shells.
390 Writes the current option settings to standard output in a format that is
391 suitable for reinput to the shell as commands that achieve the same option
398 \fB\fB-o\fR \fIoption\fR\fR
401 The \fIoption\fR argument can be one of the following option names:
405 \fB\fBallexport\fR\fR
426 All background jobs are run at a lower priority. This is the default mode.
427 \fBemacs\fR Puts you in an \fBemacs\fR style in-line editor for command entry.
436 Puts you in a \fBgmacs\fR style in-line editor for command entry.
442 \fB\fBignoreeof\fR\fR
445 The shell does not exit on end-of-file. The command \fBexit\fR must be used.
463 All directory names resulting from file name generation have a trailing \fB/\fR
479 \fB\fBnoclobber\fR\fR
482 Prevents redirection operator \fB>\fR from truncating existing files. Requires
483 the \fB>|\fR operator to truncate a file when turned on. Same as \fB-C\fR.
510 Does not save function definitions in history file.
534 \fB\fBprivileged\fR\fR
564 Puts you in insert mode of a \fBvi\fR style in-line editor until you hit escape
565 character \fB033\fR. This puts you in control mode. A return sends the line.
574 Each character is processed as it is typed in \fBvi\fR mode.
590 If no option name is supplied then the current option settings are printed.
597 Disables processing of the \fB$HOME/.profile\fR file and uses the file
598 \fB/etc/suid_profile\fR instead of the \fBENV\fR file. This mode is on whenever
599 the effective uid is not equal to the real uid, or when the effective gid is
600 not equal to the real gid. Turning this off causes the effective uid and gid to
601 be set to the real uid and gid.
610 Sorts the positional parameters lexicographically.
619 Exits after reading and executing one command.
628 Treats unset parameters as an error when substituting.
637 Prints shell input lines as they are read.
646 Prints commands and their arguments as they are executed.
655 Turns off \fB-x\fR and \fB-v\fR flags and stops examining arguments for flags.
664 Does not change any of the flags. This option is useful in setting \fB$1\fR to
665 a value beginning with \fB\(mi\fR\&. If no arguments follow this flag then the
666 positional parameters are unset.
671 Using \fB+\fR rather than \fB\(mi\fR causes these flags to be turned off. These
672 flags can also be used upon invocation of the shell. The current set of flags
673 can be found in \fB$\(mi\fR. Unless \fB-A\fR is specified, the remaining
674 arguments are positional parameters and are assigned, in order, to \fB$1\fR
675 \fB$2\fR .\|.\|.. If no arguments are specified then the names and values of
676 all variables are printed on the standard output.
679 The variables specified by the list of \fIname\fRs are unassigned, that is,
680 their values and attributes are erased. \fBreadonly\fR variables cannot be
681 unset. If the \fB-f\fR flag is set, then the names refer to \fBfunction\fR
682 names. Unsetting \fBERRNO\fR, \fBLINENO\fR, \fBMAILCHECK\fR, \fBOPTARG\fR,
683 \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and \fB_\fR removes
684 their special meaning even if they are subsequently assigned.
687 When using \fBunset\fR, the variables specified by the list of \fIname\fRs are
688 unassigned, i.e., their values and attributes are erased. \fBreadonly\fR
689 variables cannot be unset. If the \fB-f\fR, flag is set, then the names refer
690 to \fBfunction\fR names. Unsetting \fBERRNO\fR, \fBLINENO\fR, \fBMAILCHECK\fR,
691 \fBOPTARG\fR, \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and
692 \fB_\fR removes their special meaning even if they are subsequently assigned.
695 With the \fBexport\fR built-in, the specified \fIname\fRs are marked for
696 automatic export to the \fBenvironment\fR of subsequently-executed commands.
699 When \fB-p\fR is specified, \fBexport\fR writes to the standard output the
700 names and values of all exported variables in the following format:
704 "export %s=%s\en", \fIname\fR, \fIvalue\fR
711 if \fIname\fR is set, and:
715 "export %s\en", \fIname\fR
722 if \fIname\fR is unset.
725 The shell formats the output, including the proper use of quoting, so that it
726 is suitable for reinput to the shell as commands that achieve the same
727 exporting results, except for the following:
731 Read-only variables with values cannot be reset.
736 Variables that were unset at the time they were output are not reset to the
737 unset state if a value is assigned to the variable between the time the state
738 was saved and the time at which the saved output is reinput to the shell.
742 On this manual page, \fBksh\fR(1) commands that are preceded by one or two
743 \fB*\fR (asterisks) are treated specially in the following ways:
747 Variable assignment lists preceding the command remain in effect when the
753 I/O redirections are processed after variable assignments.
758 Errors cause a script that contains them to abort.
763 Words, following a command preceded by \fB**\fR that are in the format of a
764 variable assignment, are expanded with the same rules as a variable assignment.
765 This means that tilde substitution is performed after the \fB=\fR sign and word
766 splitting and file name generation are not performed.
770 \fBset\fR sets or unsets options and positional parameters. Options that are
771 specified with a \fB-\fR cause the options to be set. Options that are
772 specified with a \fB+\fR cause the option to be unset.
775 \fBset\fR without any options or arguments displays the names and values of all
776 shell variables in the order of the collation sequence in the current locale.
777 The values are quoted so that they are suitable for input again to the shell.
780 If no arguments are specified, not even the end of options argument \fB--\fR,
781 the positional parameters are unchanged. Otherwise, unless the \fB-A\fR option
782 has been specified, the positional parameters are replaced by the list of
783 arguments. A first argument of \fB--\fR is ignored when setting positional
787 For backwards compatibility, a \fBset\fR command without any options specified,
788 whose first argument is \fB-\fR turns off the \fB-v\fR and \fB-x\fR options. If
789 any additional arguments are specified, they replace the positional parameters.
792 The options for set in \fBksh93\fR are:
799 Set the export attribute for each variable whose name does not contain a . that
800 you assign a value in the current shell environment.
806 \fB\fB-A\fR \fIname\fR\fR
809 Assign the arguments sequentially to the array named by \fIname\fR starting at
810 subscript \fB0\fR rather than to the positional parameters.
819 The shell writes a message to standard error as soon it detects that a
820 background job completes rather than waiting until the next prompt.
829 Enable \fB{...}\fR group expansion. On by default.
838 Prevents existing regular files from being overwritten using the > redirection
839 operator. The \fB>|\fR redirection overrides this \fBnoclobber\fR option.
848 A simple command that has a \fBnon-zero\fR exit status causes the shell to exit
849 unless the simple command is:
854 contained in an \fB&&\fR or \fB||\fR list
860 the command immediately following \fBif\fR, \fBwhile\fR, or \fBuntil\fR
866 contained in the pipeline following \fB!\fR
876 Pathname expansion is disabled.
885 Causes \fB**\fR by itself to also match all sub-directories during pathname
895 Obsolete. Causes each command whose name has the syntax of an alias to become a
896 tracked alias when it is first encountered.
905 Enable \fB!\fR-style history expansion similar to csh.
914 This is obsolete. All arguments of the form \fIname\fR\fB=\fR\fIvalue\fR are
915 removed and placed in the variable assignment list for the command. Ordinarily,
916 variable assignments must precede command arguments.
925 When enabled, the shell runs background jobs in a separate process group and
926 displays a line upon completion. This mode is enabled by default for
927 interactive shells on systems that support job control.
936 The shell reads commands and checks for syntax errors, but does not execute the
937 command. Usually specified on command invocation.
943 \fB\fB-o\fR [\fIoption\fR]\fR
946 If option is not specified, the list of options and their current settings is
947 written to standard output. When invoked with a \fB+\fR the options are written
948 in a format that can be input again to the shell to restore the settings. This
949 option can be repeated to enable or disable multiple options.
951 The value of \fIoption\fR must be one of the following:
955 \fB\fBallexport\fR\fR
967 All background jobs are run at lower priorities.
973 \fB\fBbraceexpand\fR\fR
985 Enables or disables \fBemacs\fR editing mode.
1000 \fB\fBglobstar\fR\fR
1003 Equivalent to \fB-\fRG.
1012 Enables or disables \fBgmacs\fR. \fBgmacs\fR editing mode is the same as
1013 \fBemacs\fR editing mode, except for the handling of CTRL-T.
1019 \fB\fBhistexpand\fR\fR
1028 \fB\fBignoreeof\fR\fR
1031 The interactive shell does not exit on end-of-file.
1046 \fB\fBmarkdirs\fR\fR
1049 All directory names resulting from file name generation have a trailing \fB/\fR
1065 \fB\fBmultiline\fR\fR
1068 Use multiple lines when editing lines that are longer than the window width.
1074 \fB\fBnoclobber\fR\fR
1104 This has no effect. It is provided for backward compatibility.
1128 \fB\fBpipefail\fR\fR
1131 A pipeline does not complete until all components of the pipeline have
1132 completed, and the exit status of the pipeline is the value of the last command
1133 to exit with \fBnon-zero\fR exit status, or is \fBzero\fR if all commands
1134 return zero exit status.
1140 \fB\fBprivileged\fR\fR
1152 Simple commands preceded by a ; are traced as if \fB-x\fR were enabled but not
1159 \fB\fBtrackall\fR\fR
1180 Enables or disables \fBvi\fR editing mode.
1189 Does not use canonical input mode when using vi edit mode
1209 Privileged mode. Disabling \fB-p\fR sets the effective user id to the real user
1210 id, and the effective group id to the real group id. Enabling \fB-p\fR restores
1211 the effective user and group ids to their values when the shell was invoked.
1212 The \fB-p\fR option is on whenever the real and effective user id is not equal
1213 or the real and effective group id is not equal. User profiles are not
1214 processed when \fB-p\fR is enabled.
1223 Restricted. Enables restricted shell. This option cannot be unset once enabled.
1232 Sort the positional parameters
1241 Obsolete. The shell reads one command and then exits.
1250 If enabled, the shell displays an error message when it tries to expand a
1251 variable that is unset.
1260 Verbose. The shell displays its input onto standard error as it reads it.
1269 Execution trace. The shell displays each command after all expansion and before
1270 execution preceded by the expanded value of the \fBPS4\fR parameter.
1275 The following exit values are returned by \fBset\fR in \fBksh93\fR:
1282 Successful completion.
1296 For each name specified, \fBunset\fR unsets the variable, or function if
1297 \fB-f\fR is specified, from the current shell execution environment. Read-only
1298 variables cannot be unset.
1301 The options for \fBunset\fR in \fBksh93\fR are:
1308 Where \fIname\fR refers to a function name, the shell unsets the function
1318 If \fIname\fR refers to variable that is a reference, the variable \fIname\fR
1319 is unset rather than the variable it references. Otherwise, this option is
1320 equivalent to the \fB-v\fR option.
1329 Where \fIname\fR refers to a variable name, the shell unsets it and removes it
1330 from the environment. This is the default behavior.
1335 The following exit values are returned by \fBunset\fR in \fBksh93\fR:
1342 Successful completion. All names were successfully unset.
1351 An error occurred, or one or more \fIname\fR operands could not be unset
1356 \fBexport\fR sets the export attribute on each of the variables specified by
1357 name which causes them to be in the environment of subsequently executed
1358 commands. If \fB=\fR\fIvalue\fR is specified, the variable \fIname\fR is set to
1362 If no \fIname\fR is specified, the names and values of all exported variables
1363 are written to standard output.
1366 \fBexport\fR is built-in to the shell as a declaration command so that field
1367 splitting and pathname expansion are not performed on the arguments. Tilde
1368 expansion occurs on value.
1371 The options for \fBexport\fR in \fBksh93\fR are:
1378 Causes the output to be in the form of \fBexport\fR commands that can be used
1379 as input to the shell to recreate the current exports.
1384 The following exit values are returned by \fBexport\fR in \fBksh93\fR:
1391 Successful completion.
1405 On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
1406 \fB+\fR are treated specially in the following ways:
1410 Variable assignment lists preceding the command remain in effect when the
1416 I/O redirections are processed after variable assignments.
1421 Errors cause a script that contains them to abort.
1426 They are not valid function names.
1431 Words, following a command preceded by \fB++\fR that are in the format of a
1432 variable assignment, are expanded with the same rules as a variable assignment.
1433 This means that tilde substitution is performed after the \fB=\fR sign and
1434 field splitting and file name generation are not performed.
1439 The following example sets the \fBPATH\fR variable to search for files in the
1440 \fB/bin\fR, \fB/usr/bin\fR, \fB/usr/sbin\fR, and \fB/usr/ucb/bin\fR
1441 directories, in that order:
1445 setenv PATH "/bin:/usr/bin:/usr/sbin:usr/ucb/bin"
1452 \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBread\fR(1), \fBsh\fR(1),
1453 \fBtypeset\fR(1), \fBattributes\fR(5), \fBenviron\fR(5)