1typeset(1) User Commands typeset(1)
2
3
4
6 typeset, whence - shell built-in functions to set/get attributes and
7 values for shell variables and functions
8
10 typeset [± HLRZfilrtux [n]] [name[=value]]...
11
12
13 whence [-pv] name...
14
15
16 ksh93
17 ++typeset [±AHflbnprtux] [±EFLRZi[n]] [vname[=value]]
18
19
20 whence [-afpv] name...
21
22
24 ksh
25 typeset sets attributes and values for shell variables and functions.
26 When typeset is invoked inside a function, a new instance of the vari‐
27 ables name is created. The variables value and type are restored when
28 the function completes. The following list of attributes can be speci‐
29 fied:
30
31 -f The names refer to function names rather than variable names. No
32 assignments can be made and the only other valid flags are -t, -u
33 and -x. The flag -t turns on execution tracing for this function.
34 The flag -u causes this function to be marked undefined. The
35 FPATH variable is searched to find the function definition when
36 the function is referenced. The flag -x allows the function defi‐
37 nition to remain in effect across shell procedures invoked by
38 name.
39
40
41 -H This flag provides UNIX to hostname file mapping on non-UNIX
42 machines.
43
44
45 -i Parameter is an integer. This makes arithmetic faster. If n is
46 non-zero it defines the output arithmetic base; otherwise, the
47 first assignment determines the output base.
48
49
50 -l All uppercase characters are converted to lowercase. The upper‐
51 case flag, -u is turned off.
52
53
54 -L Left justify and remove leading blanks from value. If n is non-
55 zero it defines the width of the field; otherwise, it is deter‐
56 mined by the width of the value of first assignment. When the
57 variable is assigned to, it is filled on the right with blanks or
58 truncated, if necessary, to fit into the field. Leading zeros are
59 removed if the -Z flag is also set. The -R flag is turned off.
60
61
62 -r The specified names are marked readonly and these names cannot be
63 changed by subsequent assignment.
64
65
66 -R Right justify and fill with leading blanks. If n is non-zero it
67 defines the width of the field, otherwise it is determined by the
68 width of the value of first assignment. The field is left filled
69 with blanks or truncated from the end if the variable is reas‐
70 signed. The -L flag is turned off.
71
72
73 -t Tags the variables. Tags are user definable and have no special
74 meaning to the shell.
75
76
77 -u All lowercase characters are converted to uppercase characters.
78 The lowercase flag, -l is turned off.
79
80
81 -x The specified names are marked for automatic export to the envi‐
82 ronment of subsequently-executed commands.
83
84
85 -Z Right justify and fill with leading zeros if the first non-blank
86 character is a digit and the -L flag has not been set. If n is
87 non-zero it defines the width of the field. Otherwise, it is
88 determined by the width of the value of first assignment.
89
90
91
92 The -i attribute can not be specified along with -R, -L, -Z, or -f.
93
94
95 Using + rather than − causes these flags to be turned off. If no name
96 arguments are specified but flags are specified, a list of names (and
97 optionally the values) of the variables which have these flags set is
98 printed. (Using + rather than − keeps the values from being printed.)
99 If no names and flags are specified, the names and attributes of all
100 variables are printed.
101
102
103 For each name, whence indicates how it would be interpreted if used as
104 a command name.
105
106
107 The -v flag produces a more verbose report.
108
109
110 The -p flag does a path search for name even if name is an alias, a
111 function, or a reserved word.
112
113
114 On this manual page, ksh(1) commands that are preceded by one or two *
115 (asterisks) are treated specially in the following ways:
116
117 1. Variable assignment lists preceding the command remain in
118 effect when the command completes.
119
120 2. I/O redirections are processed after variable assignments.
121
122 3. Errors cause a script that contains them to abort.
123
124 4. Words, following a command preceded by ** that are in the
125 format of a variable assignment, are expanded with the same
126 rules as a variable assignment. This means that tilde sub‐
127 stitution is performed after the = sign and word splitting
128 and file name generation are not performed.
129
130 ksh93
131 If the -f option is not specified, typeset sets, unsets, or displays
132 attributes of variables as specified with the options. If the first
133 option is specified with a - then the attributes are set for each of
134 the specified names. If the first option is specified with a +, then
135 the specified attributes are unset. If =value is specified, value is
136 assigned before the attributes are set.
137
138
139 When typeset is called inside a function that is defined with the func‐
140 tion reserved word, and name does not contain a ., a local variable
141 statically scoped to that function is created.
142
143
144 Not all option combinations are possible. For example, the numeric
145 options -i, -E, and -F cannot be specified with the justification
146 options -L, -R, and -Z.
147
148
149 The following preset aliases are set by the shell:
150
151 float typeset -E
152
153
154 functions typeset -f
155
156
157 integer typeset -i
158
159
160 nameref typeset -n
161
162
163
164 If no names are specified, variables that have the specified options
165 are displayed. If the first option is specified with a leading - then
166 the name and value of each variable is written to standard output. Oth‐
167 erwise, only the names are written. If no options or only the -p option
168 are specified, the names and attributes of all variables that have
169 attributes are written to standard output. When -f is specified, the
170 names displayed are function names.
171
172
173 If -f is specified, then each name refers to a function and the only
174 valid options are -u and -t. In this case no =value can be specified.
175
176
177 typeset is built-in to the shell as a declaration command so that field
178 splitting and pathname expansion are not performed on the arguments.
179 Tilde expansion occurs on value.
180
181
182 The following options are supported by the typeset built-in command in
183 ksh93:
184
185 -a Indexed array. This is the default.
186
187
188 -A Associative array. Each name is converted to an associa‐
189 tive array. If a variable already exists, the current
190 value becomes index 0.
191
192
193 -b Each name can contain binary data. Its value is the mime
194 base64 encoding of the data. This option can be used with
195 -Z, to specify fixed sized fields.
196
197
198 -C Reserved for future use.
199
200
201 -E [n] Floating point number represented in scientific notation.
202 n specifies the number of significant figures when the
203 value is expanded. The default value is 10.
204
205
206 -f Each of the options and names refers to a function.
207
208
209 -F [n] Floating point. n is the number of places after the deci‐
210 mal point when the value is expanded. The default value is
211 10.
212
213
214 -h Reserved for future use.
215
216
217 -H Hostname mapping. Each name holds a native pathname.
218 Assigning a UNIX format pathname causes it to be converted
219 to a pathname suitable for the current host. This has no
220 effect when the native system is UNIX.
221
222
223 -i [base] An integer. base represents the arithmetic base from 2 to
224 64. The option value can be omitted. The default value is
225 10.
226
227
228 -l Convert uppercase characters to lowercase characters.
229 Unsets the -u option. When used with -i, -E, or -F indi‐
230 cates long variant.
231
232
233 -L [n] Left justify. If n is specified, it represents the field
234 width. If the -Z attribute is also specified, then leading
235 zeros are stripped. The option value can be omitted.
236
237
238 -n Name reference. The value is the name of a variable that
239 name references. name cannot contain a ..
240
241
242 -p Causes the output to be in a format that can be used as
243 input to the shell to recreate the attributes for vari‐
244 ables.
245
246
247 -r Enables read-only. Once this option is enabled, it cannot
248 be disabled. See readonly(1).
249
250
251 -R [n] Right justify. If n is specified it represents the field
252 width. If the -Z option is also specified, zeros are used
253 as the fill character. Otherwise, SPACEs are used.
254
255
256 -s Restricts integer size to short when used with -i.
257
258
259 -S When used inside a function defined with the function
260 reserved word, the specified variables will have function
261 static scope.
262
263
264 -t When used with -f, enables tracing for each of the speci‐
265 fied functions. Otherwise, -t is a user defined attribute
266 and has no meaning to the shell.
267
268
269 -T tname tname is the name of a type name given to each name.
270
271
272 -u Without -f or -i, converts lowercase characters to upper‐
273 case and unsets -l. When used with -f, specifies that name
274 is a function that has not yet been loaded. When used with
275 -i specifies that the value is displayed as an unsigned
276 integer.
277
278
279 -x Puts each name on the export list. See export(1). name
280 cannot contain a ..
281
282
283 -X [n] Floating point number represented in hexadecimal notation.
284 n specifies the number of significant figures when the
285 value is expanded. The option value may be omitted. The
286 default value is 10.
287
288
289 -Z [n] Zero fill. If n is specified it represents the field
290 width. The option value can be omitted.
291
292
293
294 The following exit values are returned by typeset in ksh93:
295
296 0 Successful completion.
297
298
299 >0 An error occurred.
300
301
302
303 If the -v is not specified, whence writes on standard output an abso‐
304 lute pathname, if any, corresponding to name based on the complete
305 search order that the shell uses. If name is not found, no output is
306 produced.
307
308
309 If the -v is specified, the output from whence also contains informa‐
310 tion that indicates how the specified name would be interpreted by the
311 shell in the current execution environment.
312
313
314 The following options are supported by the whence built-in command in
315 ksh93:
316
317 -a Display all uses for each name rather than the first.
318
319
320 -f Do not check for functions.
321
322
323 -p Do not check to see if name is a reserved word, a built-in, an
324 alias, or a function.
325
326
327 -v For each name specified, the shell displays a line that indicates
328 if that name is one of the following:
329
330 o Reserved word
331
332 o Alias
333
334 o Built-in
335
336 o Undefined function
337
338 o Function
339
340 o Tracked alias
341
342 o Program
343
344 o Not found
345
346
347
348 The following exit values are returned by whence in ksh93:
349
350 0 Successful completion. Each name was found by the shell.
351
352
353 1 One or more names were not found by the shell.
354
355
356 >1 An error occurred.
357
358
359
360 On this manual page, ksh93(1) commands that are preceded by one or two
361 + (plus signs) are treated specially in the following ways:
362
363 1. Variable assignment lists preceding the command remain in
364 effect when the command completes.
365
366 2. I/O redirections are processed after variable assignments.
367
368 3. Errors cause a script that contains them to abort.
369
370 4. They are not valid function names.
371
372 5. Words, following a command preceded by ++ that are in the
373 format of a variable assignment, are expanded with the same
374 rules as a variable assignment. This means that tilde sub‐
375 stitution is performed after the = sign and word splitting
376 and file name generation are not performed.
377
379 See attributes(5) for descriptions of the following attributes:
380
381
382
383
384 ┌─────────────────────────────┬─────────────────────────────┐
385 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
386 ├─────────────────────────────┼─────────────────────────────┤
387 │Availability │SUNWcsu │
388 └─────────────────────────────┴─────────────────────────────┘
389
391 ksh(1), ksh93(1), readonly(1), set(1), sh(1), attributes(5)
392
393
394
395SunOS 5.11 11 Aug 2009 typeset(1)