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]]...
99 The \fBset\fR built-in command has the following options:
106 Does not change any of the flags. This option is useful in setting \fB$1\fR to
116 Marks variables which are modified or created for export.
125 Exits immediately if a command exits with a non-zero exit status.
134 Disables file name generation.
143 Locates and remembers function commands as functions are defined. Function
144 commands are normally located when the function is executed.
153 All keyword arguments are placed in the environment for a command, not just
154 those that precede the command name.
163 Reads commands but does not execute them.
172 Exits after reading and executing one command.
181 Treats unset variables as an error when substituting.
190 Prints shell input lines as they are read.
199 Prints commands and their arguments as they are executed.
204 Using \fB+\fR rather than \fB\(mi\fR causes these flags to be turned off. These
205 flags can also be used upon invocation of the shell. The current set of flags
206 can be found in \fB$\(mi\fR. The remaining \fIargument\fRs are positional
207 parameters and are assigned, in order, to \fB$1\fR, \fB$2\fR,
208 \fB\&.\|.\|.\|.\fR If no \fIargument\fRs are specified the values of all names
212 For each \fIname\fR, \fBunset\fR removes the corresponding variable or function
213 value. The variables \fBPATH\fR, \fBPS1\fR, \fBPS2\fR, \fBMAILCHECK\fR, and
214 \fBIF\fR cannot be unset.
217 With the \fBexport\fR built-in, the specified \fIname\fRs are marked for
218 automatic export to the \fIenvironment\fR of subsequently executed commands. If
219 no arguments are specified, variable names that have been marked for export
220 during the current shell's execution are listed. Function names are \fBnot\fR
225 With no arguments, \fBset\fR displays the values of all shell variables.
226 Multiword values are displayed as a parenthesized list. With the \fIvar\fR
227 argument alone, \fBset\fR assigns an empty (null) value to the variable
228 \fIvar\fR. With arguments of the form \fIvar\fR \fB=\fR \fIvalue\fR \fBset\fR
229 assigns \fIvalue\fR to \fIvar\fR, where \fIvalue\fR is one of:
236 A single word (or quoted string).
242 \fB\fB(\fR\fIwordlist\fR\fB)\fR\fR
245 A space-separated list of words enclosed in parentheses.
250 Values are command and filename expanded before being assigned. The form
251 \fBset\fR \fIvar\fR\fB[\fR\fIn\fR\fB]=\fR\fIword\fR replaces the \fIn\fR'th
252 word in a multiword value with \fIword\fR.
255 \fBunset\fR removes variables whose names match (filename substitution)
256 \fIpattern\fR. All variables are removed by `\fBunset *\fR'.
259 With no arguments, \fBsetenv\fR displays all environment variables. With the
260 \fIVAR\fR argument, \fBsetenv\fR sets the environment variable
261 \fB\fR\fIVAR\fR\fB \fR to an empty (null) value. (By convention, environment
262 variables are normally specified upper-case names.) With both \fIVAR\fR and
263 \fIword\fR arguments specified, \fBsetenv\fR sets \fIVAR\fR to \fIword\fR,
264 which must be either a single word or a quoted string. The \fBPATH\fR variable
265 can take multiple \fIword\fR arguments, separated by colons (see EXAMPLES). The
266 most commonly used environment variables, \fBUSER\fR, \fBTERM\fR, and
267 \fBPATH\fR, are automatically imported to and exported from the \fBcsh\fR
268 variables \fBuser\fR, \fBterm\fR, and \fBpath\fR. Use \fBsetenv\fR if you need
269 to change these variables. In addition, the shell sets the \fBPWD\fR
270 environment variable from the \fBcsh\fR variable \fBcwd\fR whenever the latter
274 The environment variables \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, \fBLC_TIME\fR,
275 \fBLC_COLLATE\fR, \fBLC_NUMERIC\fR, and \fBLC_MONETARY\fR take immediate effect
276 when changed within the C shell. See \fBenviron\fR(5) for descriptions of these
277 environment variables.
280 \fBunsetenv\fR removes \fIvariable\fR from the environment. As with
281 \fBunset\fR, pattern matching is not performed.
285 The flags for the \fBset\fR built-in have meaning as follows:
292 Array assignment. Unsets the variable \fIname\fR and assigns values
293 sequentially from the list \fIarg\fR. If \fB+A\fR is used, the variable
294 \fIname\fR is not unset first.
303 All subsequent variables that are defined are automatically exported.
312 Causes the shell to notify the user asynchronously of background job
322 Prevents existing files from being overwritten by the shell's \fB>\fR
323 redirection operator. The \fB>|\fR redirection operator overrides this
324 noclobber option for an individual file.
333 If a command has a non-zero exit status, executes the \fBERR\fR trap, if set,
334 and exits. This mode is disabled while reading profiles.
343 Disables file name generation.
352 Each command becomes a tracked alias when first encountered.
361 All variable assignment arguments are placed in the environment for a command,
362 not just those that precede the command name.
371 Background jobs run in a separate process group and a line prints upon
372 completion. The exit status of background jobs is reported in a completion
373 message. On systems with job control, this flag is turned on automatically for
383 Reads commands and checks them for syntax errors, but does not execute them.
384 Ignored for interactive shells.
393 Writes the current option stettings to standard output in a format that is
394 suitable for reinput to the shell as commands that achieve the same option
401 \fB\fB-o\fR \fIoption\fR\fR
404 The \fIoption\fR argument can be one of the following option names:
408 \fB\fBallexport\fR\fR
429 All background jobs are run at a lower priority. This is the default mode.
430 \fBemacs\fR Puts you in an \fBemacs\fR style in-line editor for command entry.
439 Puts you in a \fBgmacs\fR style in-line editor for command entry.
445 \fB\fBignoreeof\fR\fR
448 The shell does not exit on end-of-file. The command \fBexit\fR must be used.
466 All directory names resulting from file name generation have a trailing \fB/\fR
482 \fB\fBnoclobber\fR\fR
485 Prevents redirection operator \fB>\fR from truncating existing files. Requires
486 the \fB>|\fR operator to truncate a file when turned on. Same as \fB-C\fR.
513 Does not save function definitions in history file.
537 \fB\fBprivileged\fR\fR
567 Puts you in insert mode of a \fBvi\fR style in-line editor until you hit escape
568 character \fB033\fR. This puts you in control mode. A return sends the line.
577 Each character is processed as it is typed in \fBvi\fR mode.
593 If no option name is supplied then the current option settings are printed.
600 Disables processing of the \fB$HOME/.profile\fR file and uses the file
601 \fB/etc/suid_profile\fR instead of the \fBENV\fR file. This mode is on whenever
602 the effective uid is not equal to the real uid, or when the effective gid is
603 not equal to the real gid. Turning this off causes the effective uid and gid to
604 be set to the real uid and gid.
613 Sorts the positional parameters lexicographically.
622 Exits after reading and executing one command.
631 Treats unset parameters as an error when substituting.
640 Prints shell input lines as they are read.
649 Prints commands and their arguments as they are executed.
658 Turns off \fB-x\fR and \fB-v\fR flags and stops examining arguments for flags.
667 Does not change any of the flags. This option is useful in setting \fB$1\fR to
668 a value beginning with \fB\(mi\fR\&. If no arguments follow this flag then the
669 positional parameters are unset.
674 Using \fB+\fR rather than \fB\(mi\fR causes these flags to be turned off. These
675 flags can also be used upon invocation of the shell. The current set of flags
676 can be found in \fB$\(mi\fR. Unless \fB-A\fR is specified, the remaining
677 arguments are positional parameters and are assigned, in order, to \fB$1\fR
678 \fB$2\fR .\|.\|.. If no arguments are specified then the names and values of
679 all variables are printed on the standard output.
682 The variables specified by the list of \fIname\fRs are unassigned, that is,
683 their values and attributes are erased. \fBreadonly\fR variables cannot be
684 unset. If the \fB-f\fR flag is set, then the names refer to \fBfunction\fR
685 names. Unsetting \fBERRNO\fR, \fBLINENO\fR, \fBMAILCHECK\fR, \fBOPTARG\fR,
686 \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and \fB_\fR removes
687 their special meaning even if they are subsequently assigned.
690 When using \fBunset\fR, the variables specified by the list of \fIname\fRs are
691 unassigned, i.e., their values and attributes are erased. \fBreadonly\fR
692 variables cannot be unset. If the \fB-f\fR, flag is set, then the names refer
693 to \fBfunction\fR names. Unsetting \fBERRNO\fR, \fBLINENO\fR, \fBMAILCHECK\fR,
694 \fBOPTARG\fR, \fBOPTIND\fR, \fBRANDOM\fR, \fBSECONDS\fR, \fBTMOUT\fR, and
695 \fB_\fR removes their special meaning even if they are subsequently assigned.
698 With the \fBexport\fR built-in, the specified \fIname\fRs are marked for
699 automatic export to the \fBenvironment\fR of subsequently-executed commands.
702 When \fB-p\fR is specified, \fBexport\fR writes to the standard output the
703 names and values of all exported variables in the following format:
707 "export %s=%s\en", \fIname\fR, \fIvalue\fR
714 if \fIname\fR is set, and:
718 "export %s\en", \fIname\fR
725 if \fIname\fR is unset.
728 The shell formats the output, including the proper use of quoting, so that it
729 is suitable for reinput to the shell as commands that achieve the same
730 exporting results, except for the following:
734 Read-only variables with values cannot be reset.
739 Variables that were unset at the time they were output are not reset to the
740 unset state if a value is assigned to the variable between the time the state
741 was saved and the time at which the saved output is reinput to the shell.
745 On this manual page, \fBksh\fR(1) commands that are preceded by one or two
746 \fB*\fR (asterisks) are treated specially in the following ways:
750 Variable assignment lists preceding the command remain in effect when the
756 I/O redirections are processed after variable assignments.
761 Errors cause a script that contains them to abort.
766 Words, following a command preceded by \fB**\fR that are in the format of a
767 variable assignment, are expanded with the same rules as a variable assignment.
768 This means that tilde substitution is performed after the \fB=\fR sign and word
769 splitting and file name generation are not performed.
774 \fBset\fR sets or unsets options and positional parameters. Options that are
775 specified with a \fB-\fR cause the options to be set. Options that are
776 specified with a \fB+\fR cause the option to be unset.
779 \fBset\fR without any options or arguments displays the names and values of all
780 shell variables in the order of the collation sequence in the current locale.
781 The values are quoted so that they are suitable for input again to the shell.
784 If no arguments are specified, not even the end of options argument \fB--\fR,
785 the positional parameters are unchanged. Otherwise, unless the \fB-A\fR option
786 has been specified, the positional parameters are replaced by the list of
787 arguments. A first argument of \fB--\fR is ignored when setting positional
791 For backwards compatibility, a \fBset\fR command without any options specified,
792 whose first argument is \fB-\fR turns off the \fB-v\fR and \fB-x\fR options. If
793 any additional arguments are specified, they replace the positional parameters.
796 The options for set in \fBksh93\fR are:
803 Set the export attribute for each variable whose name does not contain a . that
804 you assign a value in the current shell environment.
810 \fB\fB-A\fR \fIname\fR\fR
813 Assign the arguments sequentially to the array named by \fIname\fR starting at
814 subscript \fB0\fR rather than to the positional parameters.
823 The shell writes a message to standard error as soon it detects that a
824 background job completes rather than waiting until the next prompt.
833 Enable \fB{...}\fR group expansion. On by default.
842 Prevents existing regular files from being overwritten using the > redirection
843 operator. The \fB>|\fR redirection overrides this \fBnoclobber\fR option.
852 A simple command that has a \fBnon-zero\fR exit status causes the shell to exit
853 unless the simple command is:
858 contained in an \fB&&\fR or \fB||\fR list
864 the command immediately following \fBif\fR, \fBwhile\fR, or \fBuntil\fR
870 contained in the pipeline following \fB!\fR
880 Pathname expansion is disabled.
889 Causes \fB**\fR by itself to also match all sub-directories during pathname
899 Obsolete. Causes each command whose name has the syntax of an alias to become a
900 tracked alias when it is first encountered.
909 Enable \fB!\fR-style history expansion similar to csh.
918 This is obsolete. All arguments of the form \fIname\fR\fB=\fR\fIvalue\fR are
919 removed and placed in the variable assignment list for the command. Ordinarily,
920 variable assignments must precede command arguments.
929 When enabled, the shell runs background jobs in a separate process group and
930 displays a line upon completion. This mode is enabled by default for
931 interactive shells on systems that support job control.
940 The shell reads commands and checks for syntax errors, but does not execute the
941 command. Usually specified on command invocation.
947 \fB\fB-o\fR [\fIoption\fR]\fR
950 If option is not specified, the list of options and their current settings is
951 written to standard output. When invoked with a \fB+\fR the options are written
952 in a format that can be input again to the shell to restore the settings. This
953 option can be repeated to enable or disable multiple options.
955 The value of \fIoption\fR must be one of the following:
959 \fB\fBallexport\fR\fR
971 All background jobs are run at lower priorities.
977 \fB\fBbraceexpand\fR\fR
989 Enables or disables \fBemacs\fR editing mode.
1004 \fB\fBglobstar\fR\fR
1007 Equivalent to \fB-\fRG.
1016 Enables or disables \fBgmacs\fR. \fBgmacs\fR editing mode is the same as
1017 \fBemacs\fR editing mode, except for the handling of CTRL-T.
1023 \fB\fBhistexpand\fR\fR
1032 \fB\fBignoreeof\fR\fR
1035 The interactive shell does not exit on end-of-file.
1050 \fB\fBmarkdirs\fR\fR
1053 All directory names resulting from file name generation have a trailing \fB/\fR
1069 \fB\fBmultiline\fR\fR
1072 Use multiple lines when editing lines that are longer than the window width.
1078 \fB\fBnoclobber\fR\fR
1108 This has no effect. It is provided for backward compatibility.
1132 \fB\fBpipefail\fR\fR
1135 A pipeline does not complete until all components of the pipeline have
1136 completed, and the exit status of the pipeline is the value of the last command
1137 to exit with \fBnon-zero\fR exit status, or is \fBzero\fR if all commands
1138 return zero exit status.
1144 \fB\fBprivileged\fR\fR
1156 Simple commands preceded by a ; are traced as if \fB-x\fR were enabled but not
1163 \fB\fBtrackall\fR\fR
1184 Enables or disables \fBvi\fR editing mode.
1193 Does not use canonical input mode when using vi edit mode
1213 Privileged mode. Disabling \fB-p\fR sets the effective user id to the real user
1214 id, and the effective group id to the real group id. Enabling \fB-p\fR restores
1215 the effective user and group ids to their values when the shell was invoked.
1216 The \fB-p\fR option is on whenever the real and effective user id is not equal
1217 or the real and effective group id is not equal. User profiles are not
1218 processed when \fB-p\fR is enabled.
1227 Restricted. Enables restricted shell. This option cannot be unset once enabled.
1236 Sort the positional parameters
1245 Obsolete. The shell reads one command and then exits.
1254 If enabled, the shell displays an error message when it tries to expand a
1255 variable that is unset.
1264 Verbose. The shell displays its input onto standard error as it reads it.
1273 Execution trace. The shell displays each command after all expansion and before
1274 execution preceded by the expanded value of the \fBPS4\fR parameter.
1279 The following exit values are returned by \fBset\fR in \fBksh93\fR:
1286 Successful completion.
1300 For each name specified, \fBunset\fR unsets the variable, or function if
1301 \fB-f\fR is specified, from the current shell execution environment. Read-only
1302 variables cannot be unset.
1305 The options for \fBunset\fR in \fBksh93\fR are:
1312 Where \fIname\fR refers to a function name, the shell unsets the function
1322 If \fIname\fR refers to variable that is a reference, the variable \fIname\fR
1323 is unset rather than the variable it references. Otherwise, this option is
1324 equivalent to the \fB-v\fR option.
1333 Where \fIname\fR refers to a variable name, the shell unsets it and removes it
1334 from the environment. This is the default behavior.
1339 The following exit values are returned by \fBunset\fR in \fBksh93\fR:
1346 Successful completion. All names were successfully unset.
1355 An error occurred, or one or more \fIname\fR operands could not be unset
1360 \fBexport\fR sets the export attribute on each of the variables specified by
1361 name which causes them to be in the environment of subsequently executed
1362 commands. If \fB=\fR\fIvalue\fR is specified, the variable \fIname\fR is set to
1366 If no \fIname\fR is specified, the names and values of all exported variables
1367 are written to standard output.
1370 \fBexport\fR is built-in to the shell as a declaration command so that field
1371 splitting and pathname expansion are not performed on the arguments. Tilde
1372 expansion occurs on value.
1375 The options for \fBexport\fR in \fBksh93\fR are:
1382 Causes the output to be in the form of \fBexport\fR commands that can be used
1383 as input to the shell to recreate the current exports.
1388 The following exit values are returned by \fBexport\fR in \fBksh93\fR:
1395 Successful completion.
1409 On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
1410 \fB+\fR are treated specially in the following ways:
1414 Variable assignment lists preceding the command remain in effect when the
1420 I/O redirections are processed after variable assignments.
1425 Errors cause a script that contains them to abort.
1430 They are not valid function names.
1435 Words, following a command preceded by \fB++\fR that are in the format of a
1436 variable assignment, are expanded with the same rules as a variable assignment.
1437 This means that tilde substitution is performed after the \fB=\fR sign and
1438 field splitting and file name generation are not performed.
1444 The following example sets the \fBPATH\fR variable to search for files in the
1445 \fB/bin\fR, \fB/usr/bin\fR, and \fB/usr/sbin\fR
1446 directories, in that order:
1450 setenv PATH "/bin:/usr/bin:/usr/sbin"
1458 \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBread\fR(1), \fBsh\fR(1),
1459 \fBtypeset\fR(1), \fBattributes\fR(5), \fBenviron\fR(5)