2 .\" Copyright 1989 AT&T
3 .\" Copyright (c) 2007 Sun Microsystems, Inc. - All Rights Reserved.
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 EXEC 1 "Apr 8, 2008"
10 exec, eval, source \- shell built-in functions to execute other commands
15 \fBexec\fR [\fIargument\fR]...
20 \fBeval\fR [\fIargument\fR]...
26 \fBexec\fR \fIcommand\fR
31 \fBeval\fR \fIargument\fR...
36 \fBsource\fR [\fB-h\fR] \fIname\fR
42 \fB*exec\fR [\fIargument\fR]...
47 \fB*eval\fR [\fIargument\fR]...
53 \fB+exec\fR [\fB-c\fR] [\fB-a\fR \fIname\fR] [\fIcommand\fR [\fIargument\fR ... ]]
58 \fB+eval\fR [\fIargument\fR]...
65 The \fBexec\fR command specified by the arguments is executed in place of this
66 shell without creating a new process. Input/output arguments and appear and, if
67 no other arguments are specified, cause the shell input/output to be modified.
70 The \fIargument\fRs to the \fBeval\fR built-in are read as input to the shell
71 and the resulting command(s) executed.
75 \fBexec\fR executes \fBcommand\fR in place of the current shell, which
79 \fBeval\fR reads its \fIargument\fRs as input to the shell and executes the
80 resulting command(s). This is usually used to execute commands generated as the
81 result of command or variable substitution.
84 \fBsource\fR reads commands from \fIname\fR. \fBsource\fR commands can be
85 nested, but if they are nested too deeply the shell can run out of file
86 descriptors. An error in a sourced file at any level terminates all nested
87 \fBsource\fR commands.
94 Place commands from the file \fIname\fR on the history list without executing
101 With the \fBexec\fR built-in, if \fIarg\fR is specified, the command specified
102 by the arguments is executed in place of this shell without creating a new
103 process. Input/output arguments can appear and affect the current process. If
104 no arguments are specified the effect of this command is to modify file
105 descriptors as prescribed by the input/output redirection list. In this case,
106 any file descriptor numbers greater than 2 that are opened with this mechanism
107 are closed when invoking another program.
110 The arguments to \fBeval\fR are read as input to the shell and the resulting
114 On this man page, \fBksh\fR(1) commands that are preceded by one or two *
115 (asterisks) are treated specially in the following ways:
119 Variable assignment lists preceding the command remain in effect when the
125 \fBI/O\fR redirections are processed after variable assignments.
130 Errors cause a script that contains them to abort.
135 Words, following a command preceded by ** that are in the format of a
136 variable assignment, are expanded with the same rules as a variable assignment.
137 This means that tilde substitution is performed after the \fB=\fR sign and word
138 splitting and file name generation are not performed.
143 \fBexec\fR is a special built-in command that can be used to manipulate file
144 descriptors or to replace the current shell with a new command.
147 If \fIcommand\fR is specified, then the current shell process is replaced by
148 \fIcommand\fR rather than running \fIcommand\fR and waiting for it to complete.
149 There is no need to use \fBexec\fR to enhance performance since the shell
150 implicitly uses the \fBexec\fR mechanism internally whenever possible.
153 If no operands are specified, \fBexec\fR can be used to open or close files, or
154 to manipulate file descriptors from \fB0\fR to \fB9\fR in the current shell
155 environment using the standard redirection mechanism available with all
156 commands. The close-on-exec flags is set on file descriptor numbers greater
157 than \fB2\fR that are opened this way so that they are closed when another
161 Because \fBexec\fR is a special command, any failure causes the script that
162 invokes it to exit. This can be prevented by invoking \fBexec\fR from the
163 \fBcommand\fR utility.
166 \fBexec\fR cannot be invoked from a restricted shell to create files or to open
167 a file for writing or appending.
170 \fBeval\fR is a shell special built-in command that constructs a command by
171 concatenating the \fIargument\fRs together, separating each with a space. The
172 resulting string is taken as input to the shell and evaluated in the current
173 environment. command words are expanded twice, once to construct
174 \fIargument\fR, and again when the shell executes the constructed command. It
175 is not an error if \fIargument\fR is not specified.
178 On this manual page, \fBksh93\fR commands that are preceded by one or two
179 \fB+\fR symbols are special built-in commands and are treated specially in the
184 Variable assignment lists preceding the command remain in effect when the
190 I/O redirections are processed after variable assignments.
195 Errors cause a script that contains them to abort.
200 They are not valid function names.
205 Words following a command preceded by \fB++\fR that are in the format of a
206 variable assignment are expanded with the same rules as a variable assignment.
207 This means that tilde substitution is performed after the \fB=\fR sign and
208 field splitting and file name generation are not performed.
214 The following options are supported by \fBksh93 exec\fR:
218 \fB\fB-a\fR \fIname\fR\fR
221 \fBargv[0]\fR is set to \fIname\fR for command.
230 Clear all environment variables before executions except variable assignments
231 that are part of the current \fBexec\fR command.
238 The following exit values are returned by \fBexec\fR:
245 Successful completion.
254 A redirection error occurred.
263 \fIcommand\fR was not found.
272 \fIcommand\fR was found, but it is not an executable utility.
278 The following exit values are returned by \fBexec\fR. If \fIcommand\fR is
279 specified, \fBexec\fR does not return.
286 Successful completion. All I/O redirections were successful.
300 The following exit values are returned by \fBeval\fR:
303 If \fIargument\fR is not specified, the exit status is \fB0\fR. Otherwise, it
304 is the exit status of the command defined by the \fIargument\fR operands.
308 See \fBattributes\fR(5) for descriptions of the following attributes:
316 ATTRIBUTE TYPE ATTRIBUTE VALUE
322 \fBcsh\fR(1), \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1), \fBattributes\fR(5)