9070 Remove wanboot from gate
[unleashed.git] / usr / src / man / man1 / typeset.1
blob9fdacf82c8637a12566ddbda0750ba66e7258297
1 '\" te
2 .\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
3 .\" Copyright 1989 AT&T Copyright
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .TH TYPESET 1 "Aug 11, 2009"
6 .SH NAME
7 typeset, whence \- shell built-in functions to set/get attributes and values
8 for shell variables and functions
9 .SH SYNOPSIS
10 .LP
11 .nf
12 \fBtypeset\fR [\(+- HLRZfilrtux [\fIn\fR]] [\fIname\fR[=\fIvalue\fR]]...
13 .fi
15 .LP
16 .nf
17 \fBwhence\fR [\fB-pv\fR] \fIname\fR...
18 .fi
20 .SS "ksh93"
21 .LP
22 .nf
23 \fB++typeset\fR [\(+-AHflbnprtux] [\(+-EFLRZi[\fIn\fR]] [\fIvname\fR[=\fIvalue\fR]]
24 .fi
26 .LP
27 .nf
28 \fBwhence\fR [\fB-afpv\fR] \fIname\fR...
29 .fi
31 .SH DESCRIPTION
32 .SS "ksh"
33 .sp
34 .LP
35 \fBtypeset\fR sets attributes and values for shell variables and functions.
36 When \fBtypeset\fR is invoked inside a function, a new instance of the
37 variables \fIname\fR is created. The variables \fIvalue\fR and \fBtype\fR are
38 restored when the function completes. The following list of attributes can be
39 specified:
40 .sp
41 .ne 2
42 .na
43 \fB\fB-f\fR\fR
44 .ad
45 .RS 6n
46 The names refer to function names rather than variable names. No assignments
47 can be made and the only other valid flags are \fB-t\fR, \fB-u\fR and \fB-x\fR.
48 The flag \fB-t\fR turns on execution tracing for this function. The flag
49 \fB-u\fR causes this function to be marked undefined. The \fBF\fR\fBPATH\fR
50 variable is searched to find the function definition when the function is
51 referenced. The flag \fB-x\fR allows the function definition to remain in
52 effect across shell procedures invoked by name.
53 .RE
55 .sp
56 .ne 2
57 .na
58 \fB\fB-H\fR\fR
59 .ad
60 .RS 6n
61 This flag provides UNIX to hostname file mapping on non-UNIX machines.
62 .RE
64 .sp
65 .ne 2
66 .na
67 \fB\fB-i\fR\fR
68 .ad
69 .RS 6n
70 Parameter is an integer. This makes arithmetic faster. If \fIn\fR is
71 \fBnon-zero\fR it defines the output arithmetic base; otherwise, the first
72 assignment determines the output base.
73 .RE
75 .sp
76 .ne 2
77 .na
78 \fB\fB-l\fR\fR
79 .ad
80 .RS 6n
81 All uppercase characters are converted to lowercase. The uppercase flag,
82 \fB-u\fR is turned off.
83 .RE
85 .sp
86 .ne 2
87 .na
88 \fB\fB-L\fR\fR
89 .ad
90 .RS 6n
91 Left justify and remove leading blanks from \fIvalue\fR. If \fIn\fR is
92 \fBnon-zero\fR it defines the width of the field; otherwise, it is determined
93 by the width of the value of first assignment. When the variable is assigned
94 to, it is filled on the right with blanks or truncated, if necessary, to fit
95 into the field. Leading zeros are removed if the \fB-Z\fR flag is also set. The
96 \fB-R\fR flag is turned off.
97 .RE
99 .sp
100 .ne 2
102 \fB\fB-r\fR\fR
104 .RS 6n
105 The specified \fIname\fRs are marked \fBreadonly\fR and these names cannot be
106 changed by subsequent assignment.
110 .ne 2
112 \fB\fB-R\fR\fR
114 .RS 6n
115 Right justify and fill with leading blanks. If \fIn\fR is \fBnon-zero\fR it
116 defines the width of the field, otherwise it is determined by the width of the
117 value of first assignment. The field is left filled with blanks or truncated
118 from the end if the variable is reassigned. The \fB-L\fR flag is turned off.
122 .ne 2
124 \fB\fB-t\fR\fR
126 .RS 6n
127 Tags the variables. Tags are user definable and have no special meaning to the
128 shell.
132 .ne 2
134 \fB\fB-u\fR\fR
136 .RS 6n
137 All lowercase characters are converted to uppercase characters. The lowercase
138 flag, \fB-l\fR is turned off.
142 .ne 2
144 \fB\fB-x\fR\fR
146 .RS 6n
147 The specified \fIname\fRs are marked for automatic export to the
148 \fBenvironment\fR of subsequently-executed commands.
152 .ne 2
154 \fB\fB-Z\fR\fR
156 .RS 6n
157 Right justify and fill with leading zeros if the first non-blank character is a
158 digit and the \fB-L\fR flag has not been set. If \fIn\fR is \fBnon-zero\fR it
159 defines the width of the field. Otherwise, it is determined by the width of the
160 value of first assignment.
165 The \fB-i\fR attribute can not be specified along with \fB-R\fR, \fB-L\fR,
166 \fB-Z\fR, or \fB-f\fR.
169 Using \fB+\fR rather than \fB\(mi\fR causes these flags to be turned off. If no
170 \fIname\fR arguments are specified but flags are specified, a list of
171 \fInames\fR (and optionally the \fIvalues\fR) of the \fIvariables\fR which have
172 these flags set is printed. (Using \fB+\fR rather than \fB\(mi\fR keeps the
173 values from being printed.) If no \fIname\fRs and flags are specified, the
174 \fInames\fR and \fIattributes\fR of all \fIvariables\fR are printed.
177 For each \fIname\fR, \fBwhence\fR indicates how it would be interpreted if used
178 as a command name.
181 The \fB-v\fR flag produces a more verbose report.
184 The \fB-p\fR flag does a path search for \fIname\fR even if name is an alias, a
185 function, or a reserved word.
188 On this manual page, \fBksh\fR(1) commands that are preceded by one or two *
189 (asterisks) are treated specially in the following ways:
190 .RS +4
193 Variable assignment lists preceding the command remain in effect when the
194 command completes.
196 .RS +4
199 I/O redirections are processed after variable assignments.
201 .RS +4
204 Errors cause a script that contains them to abort.
206 .RS +4
209 Words, following a command preceded by \fB**\fR that are in the format of a
210 variable assignment, are expanded with the same rules as a variable assignment.
211 This means that tilde substitution is performed after the \fB=\fR sign and word
212 splitting and file name generation are not performed.
214 .SS "ksh93"
217 If the \fB-f\fR option is not specified, \fBtypeset\fR sets, unsets, or
218 displays attributes of variables as specified with the options. If the first
219 option is specified with a \fB-\fR then the attributes are set for each of the
220 specified names. If the first option is specified with a \fB+\fR, then the
221 specified attributes are unset. If \fB=\fR\fIvalue\fR is specified, \fIvalue\fR
222 is assigned before the attributes are set.
225 When \fBtypeset\fR is called inside a function that is defined with the
226 \fBfunction\fR reserved word, and \fIname\fR does not contain a \fB\&.\fR, a
227 local variable statically scoped to that function is created.
230 Not all option combinations are possible. For example, the numeric options
231 \fB-i\fR, \fB-E\fR, and \fB-F\fR cannot be specified with the justification
232 options \fB-L\fR, \fB-R\fR, and \fB-Z\fR.
235 The following preset aliases are set by the shell:
237 .ne 2
239 \fB\fBfloat\fR\fR
241 .RS 13n
242 \fBtypeset\fR \fB-E\fR
246 .ne 2
248 \fB\fBfunctions\fR\fR
250 .RS 13n
251 \fBtypeset\fR \fB-f\fR
255 .ne 2
257 \fB\fBinteger\fR\fR
259 .RS 13n
260 \fBtypeset\fR \fB-i\fR
264 .ne 2
266 \fB\fBnameref\fR\fR
268 .RS 13n
269 \fBtypeset\fR \fB-n\fR
274 If no \fInames\fR are specified, variables that have the specified options are
275 displayed. If the first option is specified with a leading \fB-\fR then the
276 name and value of each variable is written to standard output. Otherwise, only
277 the names are written. If no options or only the \fB-p\fR option are specified,
278 the names and attributes of all variables that have attributes are written to
279 standard output. When \fB-f\fR is specified, the names displayed are function
280 names.
283 If \fB-f\fR is specified, then each name refers to a function and the only
284 valid options are \fB-u\fR and \fB-t\fR. In this case no \fB=\fR\fIvalue\fR can
285 be specified.
288 \fBtypeset\fR is built-in to the shell as a declaration command so that field
289 splitting and pathname expansion are not performed on the arguments. Tilde
290 expansion occurs on \fIvalue\fR.
293 The following options are supported by the \fBtypeset\fR built-in command in
294 \fBksh93\fR:
296 .ne 2
298 \fB\fB-a\fR\fR
300 .RS 13n
301 Indexed array. This is the default.
305 .ne 2
307 \fB\fB-A\fR\fR
309 .RS 13n
310 Associative array. Each \fIname\fR is converted to an associative array. If a
311 variable already exists, the current value becomes index \fB0\fR.
315 .ne 2
317 \fB\fB-b\fR\fR
319 .RS 13n
320 Each name can contain binary data. Its value is the mime \fBbase64\fR encoding
321 of the data. This option can be used with \fB-Z\fR, to specify fixed sized
322 fields.
326 .ne 2
328 \fB\fB-C\fR\fR
330 .RS 13n
331 Reserved for future use.
335 .ne 2
337 \fB\fB-E\fR [\fIn\fR]\fR
339 .RS 13n
340 Floating point number represented in scientific notation. \fIn\fR specifies the
341 number of significant figures when the value is expanded. The default value is
342 \fB10\fR.
346 .ne 2
348 \fB\fB-f\fR\fR
350 .RS 13n
351 Each of the options and names refers to a function.
355 .ne 2
357 \fB\fB-F\fR [\fIn\fR]\fR
359 .RS 13n
360 Floating point. \fIn\fR is the number of places after the decimal point when
361 the value is expanded. The default value is \fB10\fR.
365 .ne 2
367 \fB\fB-h\fR\fR
369 .RS 13n
370 Reserved for future use.
374 .ne 2
376 \fB\fB-H\fR\fR
378 .RS 13n
379 Hostname mapping. Each name holds a native pathname. Assigning a UNIX format
380 pathname causes it to be converted to a pathname suitable for the current host.
381 This has no effect when the native system is UNIX.
385 .ne 2
387 \fB\fB-i\fR [\fIbase\fR]\fR
389 .RS 13n
390 An integer. \fIbase\fR represents the arithmetic base from \fB2\fR to \fB64\fR.
391 The option value can be omitted. The default value is \fB10\fR.
395 .ne 2
397 \fB\fB-l\fR\fR
399 .RS 13n
400 Convert uppercase characters to lowercase characters. Unsets the \fB-u\fR
401 option. When used with \fB-i\fR, \fB-E\fR, or \fB-F\fR indicates long variant.
405 .ne 2
407 \fB\fB-L\fR [\fIn\fR]\fR
409 .RS 13n
410 Left justify. If \fIn\fR is specified, it represents the field width. If the
411 \fB-Z\fR attribute is also specified, then leading zeros are stripped. The
412 option value can be omitted.
416 .ne 2
418 \fB\fB-n\fR\fR
420 .RS 13n
421 Name reference. The value is the name of a variable that \fIname\fR references.
422 \fIname\fR cannot contain a \fB\&.\fR.
426 .ne 2
428 \fB\fB-p\fR\fR
430 .RS 13n
431 Causes the output to be in a format that can be used as input to the shell to
432 recreate the attributes for variables.
436 .ne 2
438 \fB\fB-r\fR\fR
440 .RS 13n
441 Enables read-only. Once this option is enabled, it cannot be disabled. See
442 \fBreadonly\fR(1).
446 .ne 2
448 \fB\fB-R\fR [\fIn\fR]\fR
450 .RS 13n
451 Right justify. If \fIn\fR is specified it represents the field width. If the
452 \fB-Z\fR option is also specified, zeros are used as the fill character.
453 Otherwise, SPACEs are used.
457 .ne 2
459 \fB\fB-s\fR\fR
461 .RS 13n
462 Restricts integer size to short when used with \fB-i\fR.
466 .ne 2
468 \fB\fB-S\fR\fR
470 .RS 13n
471 When used inside a function defined with the function reserved word, the
472 specified variables will have function static scope.
476 .ne 2
478 \fB\fB-t\fR\fR
480 .RS 13n
481 When used with \fB-f\fR, enables tracing for each of the specified functions.
482 Otherwise, \fB-t\fR is a user defined attribute and has no meaning to the
483 shell.
487 .ne 2
489 \fB\fB-T\fR \fItname\fR\fR
491 .RS 13n
492 \fItname\fR is the name of a type name given to each name.
496 .ne 2
498 \fB\fB-u\fR\fR
500 .RS 13n
501 Without \fB-f\fR or \fB-i\fR, converts lowercase characters to uppercase and
502 unsets \fB-l\fR. When used with \fB-f\fR, specifies that \fIname\fR is a
503 function that has not yet been loaded. When used with \fB-i\fR specifies that
504 the value is displayed as an unsigned integer.
508 .ne 2
510 \fB\fB-x\fR\fR
512 .RS 13n
513 Puts each name on the export list. See \fBexport\fR(1). \fIname\fR cannot
514 contain a \fB\&.\fR.
518 .ne 2
520 \fB\fB-X\fR [\fIn\fR]\fR
522 .RS 13n
523 Floating point number represented in hexadecimal notation. \fIn\fR specifies
524 the number of significant figures when the value is expanded. The option value
525 may be omitted. The default value is 10.
529 .ne 2
531 \fB\fB-Z\fR [\fIn\fR]\fR
533 .RS 13n
534 Zero fill. If \fIn\fR is specified it represents the field width. The option
535 value can be omitted.
540 The following exit values are returned by \fBtypeset\fR in \fBksh93\fR:
542 .ne 2
544 \fB\fB0\fR\fR
546 .RS 6n
547 Successful completion.
551 .ne 2
553 \fB\fB>0\fR\fR
555 .RS 6n
556 An error occurred.
561 If the \fB-v\fR is not specified, \fBwhence\fR writes on standard output an
562 absolute pathname, if any, corresponding to \fIname\fR based on the complete
563 search order that the shell uses. If \fIname\fR is not found, no output is
564 produced.
567 If the \fB-v\fR is specified, the output from \fBwhence\fR also contains
568 information that indicates how the specified name would be interpreted by the
569 shell in the current execution environment.
572 The following options are supported by the \fBwhence\fR built-in command in
573 \fBksh93\fR:
575 .ne 2
577 \fB\fB-a\fR\fR
579 .RS 6n
580 Display all uses for each name rather than the first.
584 .ne 2
586 \fB\fB-f\fR\fR
588 .RS 6n
589 Do not check for functions.
593 .ne 2
595 \fB\fB-p\fR\fR
597 .RS 6n
598 Do not check to see if name is a reserved word, a built-in, an alias, or a
599 function.
603 .ne 2
605 \fB\fB-v\fR\fR
607 .RS 6n
608 For each name specified, the shell displays a line that indicates if that name
609 is one of the following:
610 .RS +4
612 .ie t \(bu
613 .el o
614 Reserved word
616 .RS +4
618 .ie t \(bu
619 .el o
620 Alias
622 .RS +4
624 .ie t \(bu
625 .el o
626 Built-in
628 .RS +4
630 .ie t \(bu
631 .el o
632 Undefined function
634 .RS +4
636 .ie t \(bu
637 .el o
638 Function
640 .RS +4
642 .ie t \(bu
643 .el o
644 Tracked alias
646 .RS +4
648 .ie t \(bu
649 .el o
650 Program
652 .RS +4
654 .ie t \(bu
655 .el o
656 Not found
662 The following exit values are returned by \fBwhence\fR in \fBksh93\fR:
664 .ne 2
666 \fB\fB0\fR\fR
668 .RS 6n
669 Successful completion. Each name was found by the shell.
673 .ne 2
675 \fB\fB1\fR\fR
677 .RS 6n
678 One or more names were not found by the shell.
682 .ne 2
684 \fB\fB>1\fR\fR
686 .RS 6n
687 An error occurred.
692 On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
693 \fB+\fR (plus signs) are treated specially in the following ways:
694 .RS +4
697 Variable assignment lists preceding the command remain in effect when the
698 command completes.
700 .RS +4
703 I/O redirections are processed after variable assignments.
705 .RS +4
708 Errors cause a script that contains them to abort.
710 .RS +4
713 They are not valid function names.
715 .RS +4
718 Words, following a command preceded by \fB++\fR that are in the format of a
719 variable assignment, are expanded with the same rules as a variable assignment.
720 This means that tilde substitution is performed after the \fB=\fR sign and word
721 splitting and file name generation are not performed.
723 .SH SEE ALSO
726 \fBksh\fR(1), \fBksh93\fR(1), \fBreadonly\fR(1), \fBset\fR(1), \fBsh\fR(1),
727 \fBattributes\fR(5)