1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
'\" te
.\" Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" To view license terms, see http://www.opensource.org/licenses/cpl1.0.txt
.\" Portions Copyright (c) 2007, Sun Microsystems, Inc.
.TH BUILTIN 1 "May 1, 2007"
.SH NAME
builtin \- ksh93 built-in function to add, delete, or display shell built-ins
.SH SYNOPSIS
.LP
.nf
\fBbuiltin\fR [\fB-ds\fR] [\fB-f\fR \fIlib\fR] [\fIpathname\fR ...]
.fi
.SH DESCRIPTION
.sp
.LP
The \fBksh93\fR \fBbuiltin\fR command adds, deletes, or displays built-in
commands in the current shell environment. A built-in command executes in the
current shell process and can have side effects in the current shell. On most
systems, the invocation time for built-in commands is one or two orders of
magnitude less than commands that create a separate process.
.sp
.LP
For each \fIpathname\fR specified, the basename of the pathname determines the
name of the built-in. For each basename, the shell looks for a C level function
in the current shell whose name is determined by pre-pending \fBb_\fR to the
built-in name. If \fIpathname\fR contains a forward slash (\fB/\fR), the
built-in is bound to \fIpathname\fR. A built-in bound to a pathname is only
executed if \fIpathname\fR is the first executable found during a path search.
Otherwise, built-ins are found prior to performing the path search.
.sp
.LP
If \fIpathname\fR is not specified, \fBbuiltin\fR displays the current list of
built-ins, or just the special built-ins if the \fB-s\fR option is specified,
on standard output. The full pathname for built-ins that are bound to pathnames
are displayed.
.sp
.LP
Libraries containing built-ins can be specified with the \fB-f\fR option. If
the library contains a function named \fBlib_init()\fR, this function is
invoked with argument \fB0\fR when the library is loaded. The \fBlib_init()\fR
function can load built-ins by invoking an appropriate C level function. In
this case there is no restriction on the C level function name.
.sp
.LP
The C level function is invoked with three arguments. The first two are the
same as \fBmain()\fR and the third one is a pointer.
.sp
.LP
The \fBksh93\fR \fBbuiltin\fR command cannot be invoked from a restricted
shell.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-d\fR\fR
.ad
.RS 10n
Delete each of the specified built-ins. Special built-ins cannot be deleted.
.RE
.sp
.ne 2
.na
\fB\fB-f\fR \fIlib\fR\fR
.ad
.RS 10n
On systems with dynamic linking, load and search for built-ins in the shared
library, \fIlib\fR.
.sp
Libraries are searched for in \fB$PATH\fR and system dependent library
directories. The system dependent shared library prefix or suffix can be
omitted. Once a library is loaded, its symbols become available for the current
and subsequent invocations of \fBbuiltin\fR. Multiple libraries can be
specified with separate invocations of \fBbuiltin\fR. Libraries are searched in
the reverse order in which they are specified.
.RE
.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 10n
Display only the special built-ins.
.RE
.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIpathname\fR\fR
.ad
.RS 12n
Specifies the \fIpathname\fR. The basename of the pathname determines the name
of the built-in.
.RE
.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE
.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE
.SH EXAMPLES
.LP
\fBExample 1 \fRLoading a \fBbuiltin\fR Command
.sp
.LP
The following example loads a \fBbuiltin\fR command \fBmycmd\fR from the
library \fBlibfoo.so\fR:
.sp
.in +2
.nf
example% builtin -f foo mycmd
.fi
.in -2
.sp
.SH AUTHORS
.sp
.LP
David Korn, \fBdgk@research.att.com\fR
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE ATTRIBUTE VALUE
_
Interface Stability Uncommitted
.TE
.SH SEE ALSO
.sp
.LP
.BR ksh93 (1),
.BR whence (1),
.BR attributes (7)
|