3 .\" AT&T Bell Laboratories
5 .\" @(#)sh.1 (dgk@research.att.com) 12/28/93
8 .nr Z 1 \" set to 1 when command name is ksh, 2 for ksh93
11 .ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
12 .ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
17 .TH KSH 1 "User Environment Utilities" "RDS Standard"
24 sh, rsh, pfsh \- shell, the standard/restricted command and programming language
27 ksh, rksh, pfksh \- KornShell, a standard/restricted command and programming language
30 ksh93, rksh93, pfksh93 \- KornShell, a standard/restricted command and programming language
43 .B \(+-abcefhikmnoprstuvxBCDP
62 .B \(+-abcefhikmnoprstuvxBCD
74 is a command and programming language
75 that executes commands read from a terminal
80 is a restricted version of the
86 it is used to set up login names and execution environments whose
87 capabilities are more controlled than those of the standard shell.
90 .if \nZ=2 .I Rpfksh93\^
91 is a profile shell version of the
97 it is used to to execute commands with the attributes specified by
98 the user's profiles (see
103 for the meaning of arguments to the shell.
107 is one of the following characters:
110 \f3; & ( ) \(bv < > new-line space tab\fP
121 is a sequence of letters, digits, or underscores
122 starting with a letter or underscore.
123 Identifiers are used as components of
128 is a sequence of one or more identifiers
129 separated by a \fB\s+2.\s-2\fP and optionally preceded
130 by a \fB\s+2.\s-2\fP.
131 Vnames are used as function and variable names.
136 from the character set defined by the current locale,
142 is a sequence of characters in the syntax
143 of the shell language.
144 The shell reads each command and
145 carries out the desired action either directly or by invoking
147 A built-in command is a command that is carried out by the
148 shell itself without creating a separate process.
149 Some commands are built-in purely for convenience
150 and are not documented here.
152 side effects in the shell environment and
153 built-ins that are found before performing a
158 For historical reasons, some of
159 these built-ins behave differently than
160 other built-ins and are called
161 .IR "special built-ins" .
165 is a list of variable assignments
167 .I Variable Assignments\^
172 which may be preceded by a list of variable assignments
176 The first word specifies the name of the command to
178 Except as specified below,
179 the remaining words are passed as arguments
180 to the invoked command.
181 The command name is passed as argument 0
186 of a simple-command is its exit status; 0-255
187 if it terminates normally; 256+\f2signum\^\fP if
188 it terminates abnormally (the name of the signal corresponding
189 to the exit status can be
198 is a sequence of one or more
202 The standard output of each command but the last
205 to the standard input of the next command.
207 except possibly the last,
208 is run as a separate process;
209 the shell waits for the last command to terminate.
210 The exit status of a pipeline is the exit
211 status of the last command unless the
214 Each pipeline can be preceded by the
217 which causes the exit status of the pipeline to become
218 0 if the exit status of the last command is non-zero, and
219 1 if the exit status of the last command is 0.
223 is a sequence of one or more
232 and optionally terminated by
237 Of these five symbols,
242 have equal precedence,
243 which is lower than that of
251 also have equal precedence.
254 causes sequential execution of the preceding pipeline; an ampersand
256 causes asynchronous execution of the preceding pipeline (i.e., the shell does
258 wait for that pipeline to finish).
261 causes asynchronous execution of the preceding pipeline
262 with a two-way pipe established to the parent shell;
263 the standard input and output of the spawned pipeline
264 can be written to and read from by the parent shell
266 the redirection operators
272 to commands and by using
275 the built-in commands
282 .RB (\| \(bv\|\(bv \^)
285 following it to be executed only if the preceding
287 returns a zero (non-zero) value.
288 One or more new-lines may appear in a
290 instead of a semicolon,
291 to delimit a command.
298 that is a simple command not beginning
299 with a redirection, and not occurring within a
305 can be preceded by a semicolon.
307 is ignored unless the
309 option is enabled as described with
316 is either a simple-command
317 or one of the following.
318 Unless otherwise stated,
319 the value returned by a command is that of the
320 last simple-command executed in the command.
322 \f3for\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
339 command executes the \f3do\fP \f2list\^\fP once for each positional parameter
340 that is set starting from
343 .I "Parameter Expansion\^"
345 Execution ends when there are no more words in the list.
347 \f3for ((\fP \*(OK\f2expr1\^\fP\*(CK \f3;\fP \*(OK\f2expr2\^\fP\*(CK \f3;\fP \*(OK\f2expr3\^\fP\*(CK \f3))\fP \f3;do\fP \f2list\^\fP \f3;done\fP
348 The arithmetic expression
352 .I "Arithmetic evaluation"
354 The arithmetic expression
356 is repeatedly evaluated until it evaluates to zero and when non-zero,
358 is executed and the arithmetic expression
362 is omitted, then it behaves as if it evaluated to 1.
364 \f3select\fP \f2vname\^\fP \*(OK \f3in\fP \f2word\^\fP .\|.\|. \*(CK \f3;do\fP \f2list\^\fP \f3;done\fP
367 command prints on standard error (file descriptor 2) the set of
369 each preceded by a number.
375 positional parameters starting from
379 .I "Parameter Expansion\^"
385 and a line is read from the standard input.
386 If this line consists of the number
389 then the value of the variable
393 corresponding to this number.
394 If this line is empty, the selection list is
396 Otherwise the value of the variable
400 The contents of the line read from standard input is
407 is executed for each selection until a
419 then the selection list is printed before
423 prompt for the next selection.
425 \f3case\fP \f2word\^\fP \f3in\fP \*(OK \*(OK\f3(\fP\*(CK\f2pattern\^\fP \*(OK \(bv \f2pattern\^\fP \*(CK .\|.\|. \f3)\fP \f2list\^\fP \f3;;\fP \*(CK .\|.\|. \f3esac\fP
430 associated with the first
434 The form of the patterns is
435 the same as that used for
436 file-name generation (see
437 .I "File Name Generation\^"
441 operator causes execution of
448 the next subsequent list, if any, is executed.
450 \f3if\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(OK \
451 \f3;elif\fP \f2list\^\fP \f3;then\fP \f2list\^\fP \*(CK .\|.\|. \
452 \*(OK \f3;else\fP \f2list\^\fP \*(CK \f3;f\&i\fP
455 following \f3if\fP is executed and,
457 returns a zero exit status, the
466 is executed and, if its value is zero,
473 Failing each successive
483 has non-zero exit status
489 command returns a zero exit status.
492 \f3while\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
494 \f3until\fP \f2list\^\fP \f3;do\fP \f2list\^\fP \f3;done\fP
498 command repeatedly executes the
501 and, if the exit status of the last command in the list is zero, executes
505 otherwise the loop terminates.
506 If no commands in the
509 are executed, then the
511 command returns a zero exit status;
513 may be used in place of
516 the loop termination test.
518 \f3((\fP\f2expression\^\fP\f3))\fP
522 is evaluated using the rules for arithmetic evaluation described below.
523 If the value of the arithmetic expression is non-zero, the exit
524 status is 0, otherwise the exit status is 1.
526 \f3(\fP\f2list\^\fP\f3)\fP
530 in a separate environment.
531 Note, that if two adjacent open parentheses are
532 needed for nesting, a space must be inserted to avoid
533 evaluation as an arithmetic command as described above.
535 \f3{ \fP\f2list\^\fP\f3;}\fP
539 Note that unlike the metacharacters
547 .IR "reserved word" s
549 at the beginning of a line or after a
551 in order to be recognized.
553 \f3[[\fP\f2 expression \^\fP\f3]]\fP
557 and returns a zero exit status when
561 .I "Conditional Expressions\^"
562 below, for a description of
566 \f3function\fP \f2varname\^\fP \f3{\fP \f2list\^\fP \f3;}\fP
568 \f2varname\^\fP \f3() {\fP \f2list\^\fP \f3;}\fP
570 Define a function which is referenced by
576 is called a discipline function and the portion
581 must refer to an existing variable.
582 The body of the function is the
588 A function defined with the \f3function\fP \f2varname\^\fP
589 syntax can also be used as an argument to the \f3.\fP
590 special built-in command to get the equivalent behavior
591 as if the \f2varname\^\fP\f3()\fP syntax were used to define it.
596 \f3time\fP \*(OK \f2pipeline\^\fP \*(CK
598 If \f2pipeline\^\fP is omitted the user and system time for
599 the current shell and completed child processes is printed
603 is executed and the elapsed time as well as
604 the user and system time are printed on standard error.
608 variable may be set to a format string that specifies how the timing
609 information should be displayed.
613 for a description of the
618 The following reserved words
619 are recognized as reserved only when they are the first word of a command
624 .if n if then else elif fi case esac for while until do done { } function select time [[ ]] !
625 .if t if then else elif fi case esac for while until do done { } function select time [[ ]] !
627 .SS Variable Assignments.
628 One or more variable assignments can start a simple command
629 or can be arguments to the
635 special built-in commands as well as
636 to other declaration commands created as types.
637 The syntax for an \f2assignment\^\fP is of the form:
640 \f2varname\^\fP\f3=\fP\f2word\^\fP
642 \f2varname\^\fP\f3[\fP\f2word\^\fP\f3]\fP=\fP\f2word\^\fP
644 No space is permitted between \f2varname\^\fP and the \f3=\fP or
645 between \f3=\fP and \fIword\^\fP.
647 \f2varname\^\fP\f3=(\fP\f2assign_list\^\fP\f3)\fP
648 No space is permitted between \f2varname\^\fP and the \f3=\fP.
649 An \f2assign_list\^\fP can be one of the following:
654 Indexed array assignment.
656 \f3[\fP\f2word\^\fP\f3]=\fP\f2word\^\fP .\|.\|.
657 Associative array assignment.
660 this will create an indexed array instead.
662 \f2assignment\^\fP .\|.\|.
663 Compound variable assignment.
664 This creates a compound variable \f2varname\^\fP with
665 sub-variables of the form \f2varname\^\fP\f3.\fP\f2name\^\fP,
666 where \f2name\^\fP is the name portion of \f2assignment\^\fP.
667 The value of \f2varname\^\fP will contain all the assignment elements.
668 Additional assignments made to sub-variables of \f2varname\^\fP
669 will also be displayed as part of the value of \f2varname\^\fP.
670 If no \f2assignment\fPs are specified, \f2varname\^\fP will be
671 a compound variable allowing subsequence child elements to be defined.
673 \f3typeset\fP \*(OK\f2options\fP\*(CK \f2assignment\^\fP .\|.\|.
674 Nested variable assignment. Multiple assignments
675 can be specified by separating each of them with a \f3;\fP.
676 The previous value is unset before the assignment.
677 Other declaration commands such as
681 other declaration commands can be used in place of
684 \f3\|.\fP \f2filename\^\fP
685 Include the assignment commands contained in
690 In addition, a \f3+=\fP can be used in place of the \f3=\fP
691 to signify adding to or appending to the previous value.
692 When \f3+=\fP is applied to an arithmetic type, \f2word\^\fP
693 is evaluated as an arithmetic expression and added to the current value.
694 When applied to a string variable, the value defined by \f2word\^\fP
695 is appended to the value. For compound assignments, the previous
696 value is not unset and the new values are appended to the
697 current ones provided that the types are compatible.
699 The right hand side of a variable assignment undergoes all the expansion
700 list below except word splitting, brace expansion, and file name generation.
701 When the left hand side is an assignment is a compound variable and
702 the right hand is the name of a compound variable, the compound variable
703 on the right will be copied or appended to the compound variable on the left.
706 A word beginning with
708 causes that word and all the following characters up to a new-line
711 The first word of each command is replaced by the text of an
715 for this word has been defined.
718 name consists of any number of characters excluding metacharacters,
720 file expansion characters,
721 parameter expansion and command substitution
725 The replacement string can contain any
727 including the metacharacters listed above.
728 The first word of each command in the
731 any that are in the process of being replaced,
732 will be tested for aliases.
733 If the last character of the alias value is a
735 then the word following the alias will also be checked for alias
737 Aliases can be used to redefine
738 built-in commands but cannot be used to redefine
739 the reserved words listed above.
740 Aliases can be created and listed with the
742 command and can be removed with the
749 not while they are executed.
751 for an alias to take effect,
755 definition command has to be executed before
756 the command which references the alias is read.
758 The following aliases
759 are compiled into the shell
760 but can be unset or redefined:
764 .B "autoload=\(fmtypeset \-fu\(fm"
766 .B "command=\(fmcommand \(fm"
768 .B "compound=\(fmtypeset \-C\(fm"
772 .B "float=\(fmtypeset \-lE\(fm"
774 .B "functions=\(fmtypeset \-f\(fm"
776 .B "hash=\(fmalias \-t \-\^\-\(fm"
778 .B "history=\(fmhist \-l\(fm"
780 .B "integer=\(fmtypeset \-li\(fm"
782 .B "nameref=\(fmtypeset \-n\(fm"
784 .B "nohup=\(fmnohup \(fm"
786 .B "r=\(fmhist \-s\(fm"
788 .B "redirect=\(fmcommand exec\(fm"
790 .B "source=\(fmcommand \s+2.\s-2\(fm"
792 .B "stop=\(fmkill \-s \s-1STOP\s+1\(fm"
794 .B "suspend=\(fmkill \-s \s-1STOP\s+1 $$\(fm"
796 .B "times=\(fm{ { time;} 2>&1;}\(fm"
798 .B "type=\(fmwhence \-v\(fm"
801 .SS Tilde Substitution.
802 After alias substitution is performed, each word
803 is checked to see if it begins with an unquoted
805 For tilde substitution,
809 portion of parameter expansion
811 .I "Parameter Expansion\^"
813 If it does, then the word up to a
815 is checked to see if it matches a user name in the
816 password database (See
818 If a match is found, the
820 and the matched login name are replaced by the
821 login directory of the matched user.
822 If no match is found, the original text is left unchanged.
825 by itself, or in front of a
836 is replaced by the value of
846 .IR "variable assignment" ,
848 substitution is attempted when
849 the value of the assignment
861 .SS Command Substitution.
862 The standard output from a command list enclosed in
863 parentheses preceded by a dollar sign (
864 \f3$(\fP\f2list\^\fP\f3)\fP
866 or in a brace group preceded by a dollar sign (
867 \f3${ \fP\f2list\^\fP\f3;}\fP
868 ), or in a pair of grave accents (\^\f3\*`\^\*`\fP\^)
869 may be used as part or all
871 trailing new-lines are removed.
872 In the second case, the \f3{\fP and \f3}\fP are treated as a reserved words
873 so that \f3{\fP must be followed by a \f2blank\^\fP and \f3}\fP must
874 appear at the beginning of the line or follow a \f3;\fP.
875 In the third (obsolete) form, the string between the quotes is processed
876 for special quoting characters before the command is executed (see
879 The command substitution
880 \^\f3$(\^cat file\^)\fP\^
881 can be replaced by the equivalent but faster
882 \^\f3$(\^<file\^)\fP\^.
883 The command substitution
884 \^\f3$(\^\fP\f2n\^\fP\f3<#\^)\fP
885 will expand to the current byte offset for file descriptor
887 Except for the second form, the command list is run in a subshell so that no
888 side effects are possible.
889 For the second form, the final
891 will be recognized as a reserved word after any token.
892 .SS Arithmetic Substitution.
893 An arithmetic expression enclosed in double
894 parentheses preceded by a dollar sign (
897 is replaced by the value of the arithmetic expression
898 within the double parentheses.
899 .SS Process Substitution.
900 This feature is only available on
901 versions of the UNIX operating system that support the
903 directory for naming open files.
904 Each command argument of the form
905 \f3<(\fP\f2list\^\fP\f3)\fP
907 \f3>(\fP\f2list\^\fP\f3)\fP
910 asynchronously connected to some file in
912 The name of this file will become the argument to the command.
915 is selected then writing on this file will provide input for
920 then the file passed as an argument will contain the output of the
926 \f3paste <(cut \-f1\fP \f2file1\fP\f3) <(cut \-f3\fP \f2file2\f3) | tee >(\fP\f2process1\fP\f3) >(\fP\f2process2\fP\f3)\fP
937 the results together, and
943 as well as putting it onto the standard output.
944 Note that the file, which is passed as an argument to the command,
947 so programs that expect to
949 on the file will not work.
951 Process substitution of the form
952 \f3<(\fP\f2list\^\fP\f3)\fP
953 can also be used with the
955 redirection operator which causes the output of
957 to be standard input or the input for whatever file descriptor is specified.
958 .SS Parameter Expansion.
964 or any of the characters
975 is denoted by a \f2vname\fP.
976 To create a variable whose
978 contains a \f3\s+2.\s-2\fP,
981 consists of everything before the last \f3\s+2.\s-2\fP must already exist.
995 special built-in command.
996 The attributes supported by the shell are described
999 special built-in command.
1000 Exported variables pass values and attributes to
1003 The shell supports both indexed and associative arrays.
1004 An element of an array variable is referenced by a
1008 for an indexed array is denoted by
1010 .I arithmetic expression\^
1012 .I "Arithmetic evaluation"
1018 To assign values to an indexed array, use
1019 \f2vname\fP\f3=(\fP\f2value\fP .\|.\|.\f3)\fP or
1020 \f3set \-A\fP \f2vname\fP \f2value\fP .\|.\|. .
1021 The value of all non-negative
1022 subscripts must be in the
1024 0 through 4,194,303.
1025 A negative subscript is treated as an offset from the maximum
1026 current index +1 so that \-1 refers to the last element.
1027 Indexed arrays can be declared with the
1031 Indexed arrays need not be declared.
1032 Any reference to a variable
1033 with a valid subscript is
1034 legal and an array will be created if necessary.
1036 An associative array is created with the
1042 for an associative array is denoted by
1043 a string enclosed between
1048 Referencing any array without a subscript
1049 is equivalent to referencing the array with subscript 0.
1055 may be assigned by writing:
1058 .IB vname = value\^\|
1068 .IB vname [ subscript ]= value\^\|
1070 .IB vname [ subscript ]= value\^
1074 Note that no space is allowed before or after the
1081 is a variable that is a reference to another variable.
1082 A nameref is created with the
1086 The value of the variable at the time of the
1088 command becomes the variable that will be referenced whenever
1089 the nameref variable is used.
1090 The name of a nameref cannot contain a \fB\s+2.\s-2\fP.
1091 When a variable or function name contains a \fB\s+2.\s-2\fP, and the portion
1092 of the name up to the first \fB\s+2.\s-2\fP matches the
1093 name of a nameref, the variable referred to is obtained by
1094 replacing the nameref portion with the name of the variable
1095 referenced by the nameref.
1096 If a nameref is used as the index of a \fBfor\fP loop,
1097 a name reference is established for each item in the list.
1098 A nameref provides a convenient way to refer to the variable
1099 inside a function whose name is passed as an argument to a function.
1100 For example, if the name of a variable is passed as the first
1101 argument to a function, the command
1104 \fBtypeset \-n var=$1\fR
1107 inside the function causes references and assignments to
1109 to be references and assignments to the variable whose
1110 name has been passed to the function.
1113 If any of the floating point attributes,
1118 or the integer attribute,
1124 is subject to arithmetic evaluation as described below.
1127 Positional parameters,
1128 parameters denoted by a number,
1129 may be assigned values with the
1131 special built-in command.
1134 is set from argument zero when the shell
1140 is used to introduce substitutable
1143 \f3${\fP\f2parameter\^\fP\f3}\fP
1145 reads all the characters from
1149 as part of the same word even if it contains
1150 braces or metacharacters.
1151 The value, if any, of the parameter is substituted.
1152 The braces are required when
1154 is followed by a letter, digit, or underscore
1155 that is not to be interpreted as part of its name,
1156 when the variable name contains a \fB\s+2.\s-2\fP.
1157 The braces are also required when a variable is subscripted
1158 unless it is part of an Arithmetic Expression
1159 or a Conditional Expression.
1162 is one or more digits then it is a positional parameter.
1163 A positional parameter of more than one digit must be
1171 then all the positional
1172 parameters, starting with
1175 (separated by a field separator character).
1192 inclusive (or all elements for
1198 the first character of
1203 \f3${#\fP\f2parameter\^\fP\f3}\fP
1210 the number of positional parameters is substituted.
1211 Otherwise, the length of the value of the
1216 \f3${#\fP\f2vname\fP\f3[*]}\fP
1219 \f3${#\fP\f2vname\fP\f3[@]}\fP
1220 The number of elements in the array
1225 \f3${@\fP\f2vname\^\fP\f3}\fP
1226 Expands to the type name (See
1227 .I "Type Variables"\^
1228 below) or attributes of the variable referred to by
1231 \f3${!\fP\f2vname\^\fP\f3}\fP
1232 Expands to the name of the variable referred to by
1238 is a name reference.
1240 \f3${!\fP\f2vname\^\fP\f3[\f2subscript\^\f3]}\fP
1241 Expands to name of the subscript unless
1254 the list of array subscripts for \f2vname\^\fP
1256 For a variable that is not an array, the value is 0 if the variable
1257 is set. Otherwise it is null.
1262 same as above, except that when used in double quotes,
1263 each array subscript yields a separate
1272 to the list of subscripts between
1276 inclusive using the same quoting rules as
1279 \f3${!\fP\f2prefix\^\fP\f3*}\fP
1280 Expands to the names of the variables whose names begin with
1283 \f3${\fP\f2parameter\^\fP\f3:\-\fP\f2word\^\fP\f3}\fP
1286 is set and is non-null then substitute its value;
1287 otherwise substitute
1290 \f3${\fP\f2parameter\^\fP\f3:=\fP\f2word\^\fP\f3}\fP
1293 is not set or is null then set it to
1295 the value of the parameter is then substituted.
1296 Positional parameters may not be assigned to
1299 \f3${\fP\f2parameter\^\fP\f3:?\fP\f2word\^\fP\f3}\fP
1302 is set and is non-null then substitute its value;
1305 and exit from the shell (if not interactive).
1308 is omitted then a standard message is printed.
1310 \f3${\fP\f2parameter\^\fP\f3:+\fP\f2word\^\fP\f3}\fP
1313 is set and is non-null then substitute
1315 otherwise substitute nothing.
1319 is not evaluated unless it is
1320 to be used as the substituted string,
1321 so that, in the following example,
1325 is not set or is null:
1328 print \|${d:\-\^$(\^pwd\^)\^}
1333 is omitted from the above expressions,
1334 then the shell only checks whether
1339 \f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3:\fP\f2length\^\fP\f3}\fP
1341 \f3${\fP\f2parameter\^\fP\f3:\fP\f2offset\^\fP\f3}\fP
1342 Expands to the portion of the value of
1344 starting at the character (counting from
1346 determined by expanding
1348 as an arithmetic expression and consisting of the
1349 number of characters determined by the arithmetic expression
1352 In the second form, the remainder of the value is used.
1356 counts backwards from the end of
1358 Note that one or more
1360 is required in front of a minus sign
1361 to prevent the shell from interpreting the operator as
1369 or is an array name indexed by
1377 refer to the array index and number
1378 of elements respectively.
1381 is taken relative to one greater than the highest subscript
1383 The order for associate arrays is unspecified.
1386 \f3${\fP\f2parameter\^\fP\f3#\fP\f2pattern\^\fP\f3}\fP
1388 \f3${\fP\f2parameter\^\fP\f3##\fP\f2pattern\^\fP\f3}\fP
1393 matches the beginning of the value of
1396 this expansion is the value of the
1398 with the matched portion deleted;
1399 otherwise the value of this
1402 In the first form the smallest matching pattern is deleted and in the
1403 second form the largest matching pattern is deleted.
1409 or an array variable with subscript
1413 the substring operation is applied to each element in turn.
1416 \f3${\fP\f2parameter\^\fP\f3%\fP\f2pattern\^\fP\f3}\fP
1418 \f3${\fP\f2parameter\^\fP\f3%%\fP\f2pattern\^\fP\f3}\fP
1423 matches the end of the value of
1426 this expansion is the value of the
1428 with the matched part deleted;
1429 otherwise substitute the value of
1431 In the first form the smallest matching pattern is deleted and in the
1432 second form the largest matching pattern is deleted.
1438 or an array variable with subscript
1442 the substring operation is applied to each element in turn.
1445 \f3${\fP\f2parameter\^\fP\f3/\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
1447 \f3${\fP\f2parameter\^\fP\f3//\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
1449 \f3${\fP\f2parameter\^\fP\f3/#\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
1451 \f3${\fP\f2parameter\^\fP\f3/%\fP\f2pattern\^\fP\f3/\f2string\^\fP\f3}\fP
1455 and replaces the longest match of
1459 Each occurrence of \f3\e\fP\f2n\^\fP in
1461 is replaced by the portion of \f2parameter\^\fP
1462 that matches the \f2n\^\fP-th sub-pattern.
1464 only the first occurrence of
1470 is replaced by the given
1472 The third form restricts the pattern match to the beginning of the string
1473 while the fourth form restricts the pattern match to the end of
1479 will be deleted and the
1489 or an array variable with subscript
1493 the substitution operation is applied to each element in turn.
1498 will be re-evaluated for each element.
1502 are automatically set by the shell:
1507 The number of positional parameters in decimal.
1510 Options supplied to the shell on invocation or by
1516 The decimal value returned by the last executed command.
1519 The process number of this shell.
1522 Initially, the value of
1524 is an absolute pathname of the shell or script being executed
1527 Subsequently it is assigned the last argument of the previous command.
1528 This parameter is not set for commands which are asynchronous.
1529 This parameter is also used to hold the name of the matching
1532 file when checking for mail.
1533 While defining a compound variable or a type,
1535 is initialized as a reference to the compound variable or type.
1536 When a discipline function is invoked,
1538 is initialized as a reference to the variable associated with
1539 the call to this function.
1542 is used as the name of the first variable of a type definition,
1543 the new type is derived from the type of the first variable (See
1544 .I "Type Variables"\^
1548 The process number of the last background command invoked or
1549 the most recent job put in the background with the
1557 trap, this variable contains the current command line
1558 that is about to run.
1561 This variable contains the value of the keyboard character
1562 (or sequence of characters if the first character is an ESC, ascii
1565 been entered when processing a
1572 If the value is changed as part of the trap action, then the new
1573 value replaces the key (or key sequence) that caused the trap.
1576 The character position of the cursor at the time of the most recent
1582 The value is set to ESC when processing a
1588 .I "Vi Editing Mode"\^
1592 is null when processing a
1598 The characters in the input buffer at the time of the most recent
1602 The value is null when not processing a
1608 The pathname of the file than contains the current command.
1611 The name of the current function that is being executed.
1614 Set to the current function depth. This can be changed
1615 inside a DEBUG trap and will set the context to the specified
1619 Set during a DEBUG trap to the line number for the caller of
1623 An indexed array which stores the most recent match and sub-pattern
1624 matches after conditional pattern matches that match and after
1625 variables expansions using the operators
1632 element stores the complete match and the
1640 becomes unset when the variable that has expanded
1641 is assigned a new value.
1644 Set to the name of the variable at the time that a
1645 discipline function is invoked.
1648 Set to the name subscript of the variable at the time that a
1649 discipline function is invoked.
1652 The current depth for subshells and command substitution.
1655 Set to the value of the variable at the time that the
1659 discipline function is invoked.
1662 Set to a value that identifies the version of this shell.
1671 The current line number within the script or
1672 function being executed.
1676 The previous working directory set by the
1682 The value of the last option argument processed by the
1688 The index of the last option argument processed by the
1694 The process number of the parent of the shell.
1698 The present working directory set by the
1704 Each time this variable is referenced, a random integer,
1705 uniformly distributed between 0 and 32767, is generated.
1706 The sequence of random numbers can be initialized by assigning
1713 This variable is set by the
1718 built-in command when no arguments are supplied.
1722 Each time this variable is referenced, the number of
1723 seconds since shell invocation is returned.
1725 assigned a value, then the value returned upon reference will
1726 be the value that was assigned plus the number of seconds since the assignment.
1730 An integer variable the is incremented each time the shell
1731 is invoked and is exported.
1735 is not in the environment when the shell is invoked, it is set
1742 are used by the shell:
1748 The search path for the
1754 If this variable is set,
1755 the value is used to define the width of the edit window
1756 for the shell edit modes and for printing
1765 variable is not set,
1766 the value of this variable will be checked for the patterns
1770 below and the corresponding editing option
1771 (see Special Command
1778 If this variable is set, then
1779 parameter expansion, command substitution, and arithmetic substitution
1781 the value to generate
1782 the pathname of the script that will be
1783 executed when the shell
1784 is invoked interactively
1788 This file is typically used for
1793 The default value is \fB$HOME/.kshrc\fP.
1794 On systems that support a system wide \fB/etc/ksh.kshrc\fP initialization file,
1795 if the filename generated by the expansion of
1802 the system wide initialization file will not be executed.
1807 the default editor name for the
1819 A pattern that defines the set of filenames that will be
1820 ignored when performing filename matching.
1824 The search path for function definitions.
1825 The directories in this path are searched for a file with the same name
1826 as the function or command when a function with the
1828 attribute is referenced and when a command is not found.
1829 If an executable file with the name of that command is found,
1830 then it is read and executed
1831 in the current environment.
1835 the current directory must be represented
1838 rather than by adjacent
1840 characters or a beginning or ending
1845 Number of the current command in the history file.
1850 the default editor name for the
1856 If this variable is set when the shell is invoked, then
1857 the value is the pathname of the file that will be
1858 used to store the command history (see
1859 .I "Command Re-entry\^"
1864 If this variable is set when the shell is invoked, then
1865 the number of previously entered commands that
1866 are accessible by this shell
1867 will be greater than or equal to this number.
1872 The default argument (home directory) for the
1878 Internal field separators,
1884 that are used to separate the results of
1885 command substitution or parameter expansion
1886 and to separate fields with the built-in command
1888 The first character of the
1891 variable is used to separate arguments for the
1897 Each single occurrence of
1901 character in the string to be split,
1902 that is not in the \f2isspace\^\fP character class, and any
1903 adjacent characters in
1906 that are in the \f2isspace\^\fP character class, delimit a field.
1911 that belong to the \f2isspace\^\fP character class,
1913 In addition, if the same \f2isspace\^\fP character appears
1914 consecutively inside
1917 this character is treated as if it were not in the \f2isspace\^\fP
1926 characters delimit a null field.
1930 This variable defines the maximum number running background jobs
1931 that can run at a time. When this limit is reached, the
1932 shell will wait for a job to complete before staring a new job.
1936 This variable determines the locale category for any
1937 category not specifically selected with a variable
1947 This variable overrides the value of the
1950 variable and any other
1957 This variable determines the locale category for character
1958 collation information.
1962 This variable determines the locale category for character
1964 It determines the character classes for pattern matching (see
1965 .I "File Name Generation\^"
1970 This variable determines the locale category for the
1971 decimal point character.
1975 If this variable is set,
1976 the value is used to determine the column length for printing
1979 Select lists will print vertically until about two-thirds of
1986 If this variable is set to the name of a mail file
1991 variable is not set,
1992 then the shell informs the user of arrival of mail
1993 in the specified file.
1997 This variable specifies how often (in seconds) the
1998 shell will check for changes in the modification time
1999 of any of the files specified by the
2006 The default value is 600 seconds.
2007 When the time has elapsed
2008 the shell will check before issuing the next prompt.
2015 separated list of file names.
2016 If this variable is set,
2017 then the shell informs the user of
2018 any modifications to the specified files
2019 that have occurred within the last
2023 Each file name can be followed by a
2025 and a message that will be printed.
2026 The message will undergo parameter expansion, command substitution,
2027 and arithmetic substitution
2030 defined as the name of the file that has changed.
2031 The default message is
2032 .I you have mail in $_\^.
2036 The search path for commands (see
2039 The user may not change
2050 The value of this variable is expanded for parameter
2051 expansion, command substitution, and arithmetic substitution to define the
2052 primary prompt string which by default is
2053 .RB `` "$\|\|\|" ''.
2056 in the primary prompt string is replaced by the
2059 .I "Command Re-entry\^"
2061 Two successive occurrences of
2063 will produce a single
2065 when the prompt string is printed.
2069 Secondary prompt string, by default
2074 Selection prompt string
2082 The value of this variable is expanded for parameter evaluation,
2083 command substitution, and arithmetic substitution
2084 and precedes each line of an execution trace.
2095 the execution trace prompt is also
2102 is kept in the environment.
2103 At invocation, if the basename of this variable is
2108 then the shell becomes restricted.
2113 then the shell becomes a profile shell (see
2118 The value of this parameter is used as a format string specifying
2119 how the timing information for pipelines prefixed with the
2121 reserved word should be displayed.
2122 The \fB%\fP character introduces a format sequence that is
2123 expanded to a time value or other information.
2124 The format sequences and their meanings are as follows.
2133 The elapsed time in seconds.
2136 The number of CPU seconds spent in user mode.
2139 The number of CPU seconds spent in system mode.
2142 The CPU percentage, computed as (U + S) / R.
2146 The brackets denote optional portions.
2147 The optional \fIp\fP is a digit specifying the \fIprecision\fP,
2148 the number of fractional digits after a decimal point.
2149 A value of 0 causes no decimal point or fraction to be output.
2150 At most three places after the decimal point can be displayed;
2151 values of \fIp\fP greater than 3 are treated as 3.
2152 If \fIp\fP is not specified, the value 3 is used.
2154 The optional \fBl\fP specifies a longer format, including
2155 hours if greater than zero,
2156 minutes, and seconds of the form \fIHH\fPh\fIMM\fPm\fISS\fP.\fIFF\fPs.
2157 The value of \fIp\fP determines whether or not the fraction is
2160 All other characters are output without change and a trailing
2162 If unset, the default value, \fB$'\enreal\et%2lR\enuser\et%2lU\ensys\t%2lS'\fP,
2163 is used. If the value is null, no timing information is displayed.
2167 If set to a value greater than zero,
2170 will be the default timeout value for the
2175 compound command terminates after
2178 seconds when input is from a terminal.
2180 the shell will terminate if a line is not entered within
2181 the prescribed number of seconds while reading from a terminal.
2182 (Note that the shell can be compiled with a maximum bound
2183 for this value which cannot be exceeded.)
2187 If the value of this variable matches the pattern
2192 (see Special Command
2196 If the value matches the pattern
2200 option is turned on.
2201 If the value matches the pattern
2210 overrides the value of
2216 The shell gives default values to
2217 \f3\s-1PATH\s+1\fP, \f3\s-1PS1\s+1\fP, \f3\s-1PS2\s+1\fP,
2218 \f3\s-1PS3\s+1\fP, \f3\s-1PS4\s+1\fP, \f3\s-1MAILCHECK\s+1\fP, \f3\s-1FCEDIT\s+1\fP,
2219 \f3\s-1TMOUT\s+1\fP and \f3\s-1IFS\s+1\fP,
2231 not set at all by the shell (although
2246 .SS Field Splitting.
2247 After parameter expansion and command substitution,
2248 the results of substitutions are scanned for the field separator
2249 characters (those found in
2253 and split into distinct fields where such characters are found.
2254 Explicit null fields (\^\f3"\^"\fP or \f3\(fm\^\(fm\fP\^) are retained.
2255 Implicit null fields
2256 (those resulting from
2258 that have no values or command substitutions with no output) are removed.
2263 option is set then each of the fields resulting from
2266 are checked to see if they contain one or more of the brace patterns
2282 represents any character,
2285 .IR n1\^ , n2\^ , n3\^
2286 are signed numbers and
2288 is a format specified as used by
2290 In each case, fields are created
2291 by prepending the characters before the
2293 and appending the characters after the
2295 to each of the strings generated by the characters between
2300 The resulting fields are checked to see if they have any
2303 In the first form, a field is created for each string between
2315 The string represented by
2317 can contain embedded matching
2330 In the seconds form,
2334 must both be either upper case or both be lower case characters
2335 in the C locale. In this case a field is created for each character
2341 In the remaining forms, a field is created for each number starting at
2343 and continuing until it reaches
2351 is not specified behave as if
2360 If forms which specify
2362 any format flags, widths and precisions can be specified
2365 can end in any of the specifiers
2368 .B {a,z}{1..5..3%02d}{b..c}x
2369 expands to the 8 fields,
2379 .SS File Name Generation.
2380 Following splitting, each field is scanned for the characters
2388 option has been set.
2389 If one of these characters appears,
2390 then the word is regarded as a
2392 Each file name component that contains any pattern character
2393 is replaced with a lexicographically sorted set of names
2394 that matches the pattern
2397 If no file name is found that matches the pattern, then
2398 that component of the filename is left unchanged unless
2399 the pattern is prefixed with
2401 in which case it is removed as described below.
2406 then each file name component
2407 that matches the pattern defined by the value of
2410 is ignored when generating the matching filenames.
2422 at the start of each file name component
2423 will be ignored unless the first character of the pattern
2424 corresponding to this component is the character
2427 Note, that for other
2428 uses of pattern matching the
2432 are not treated specially.
2438 Matches any string, including the null string.
2439 When used for filename expansion,
2442 option is on, two adjacent
2445 will match all files and zero or more directories
2449 then only directories and subdirectories will match.
2452 Matches any single character.
2454 .BR \*(OK \^.\|.\|.\^ \*(CK
2455 Matches any one of the enclosed characters.
2456 A pair of characters separated by
2459 character lexically between the pair, inclusive.
2460 If the first character following the opening
2464 then any character not enclosed is matched.
2467 can be included in the character set by putting it as the
2468 first or last character.
2474 character classes can be specified with the syntax
2475 \f3[:\fP\f2class\fP\f3:]\fP
2476 where class is one of the following classes defined in the ANSI-C standard:
2477 (Note that \f3word\fP is equivalent to \f3alnum\fP plus the character \f3_\fP).
2481 .if n alnum alpha blank cntrl digit graph lower print punct space upper word xdigit
2482 .if t alnum alpha blank cntrl digit graph lower print punct space upper word xdigit
2488 an equivalence class can be specified with the syntax
2489 \f3[=\fP\f2c\fP\f3=]\fP
2490 which matches all characters with the same primary
2491 collation weight (as defined by the current locale) as
2492 the character \f2c\fP.
2498 \f3[.\fP\f2symbol\fP\f3.]\fP
2499 matches the collating symbol \f2symbol\fP.
2505 is a list of one or more patterns separated from each other
2512 signifies that all patterns must be matched whereas
2514 requires that only one pattern be matched.
2515 Composite patterns can be formed with one or more of the following sub-patterns:
2519 \f3?(\fP\f2pattern-list\^\fP\f3)\fP
2520 Optionally matches any one of the given patterns.
2522 \f3*(\fP\f2pattern-list\^\fP\f3)\fP
2523 Matches zero or more occurrences of the given patterns.
2525 \f3+(\fP\f2pattern-list\^\fP\f3)\fP
2526 Matches one or more occurrences of the given patterns.
2528 \f3{\fP\f2n\^\fP\f3}\fP(\fP\f2pattern-list\^\fP\f3)\fP
2529 Matches \f2n\^\fP occurrences of the given patterns.
2531 \f3{\fP\f2m\^\fP\f3,\fP\f2n\^\fP\f3}\fP(\fP\f2pattern-list\^\fP\f3)\fP
2532 Matches from \f2m\^\fP to \f2n\^\fP occurrences of the given patterns.
2533 If \f2m\^\fP is omitted, \f30\fP will be used. If \f2n\^\fP
2534 is omitted at least \f2m\^\fP occurrences will be matched.
2536 \f3\&@\&(\fP\f2pattern-list\^\fP\f3)\fP
2537 Matches exactly one of the given patterns.
2540 \f3!(\fP\f2pattern-list\^\fP\f3)\fP
2541 Matches anything except one of the given patterns.
2544 By default, each pattern, or sub-pattern will match the
2545 longest string possible consistent with generating
2546 the longest overall match. If more than one match is
2547 possible, the one starting closest to the beginning
2548 of the string will be chosen. However, for each of the above
2549 compound patterns a \f3\-\fP can be inserted in front of the \f3(\fP
2550 to cause the shortest match to the specified \f2pattern-list\^\fP
2553 When \f2pattern-list\^\fP is contained within parentheses,
2554 the backslash character \f3\e\fP is treated specially even
2555 when inside a character class. All ANSI-C character escapes are
2556 recognized and match the specified character. In addition
2557 the following escape sequences are recognized:
2562 Matches any character in the \f3digit\fP class.
2565 Matches any character not in the \f3digit\fP class.
2568 Matches any character in the \f3space\fP class.
2571 Matches any character not in the \f3space\fP class.
2574 Matches any character in the \f3word\fP class.
2577 Matches any character not in the \f3word\fP class.
2581 A pattern of the form
2582 \f3%(\fP\f2pattern-pair\^\fP(s)\f3)\fP
2583 is a sub-pattern that
2584 can be used to match nested character expressions.
2587 is a two character sequence which cannot contain
2593 specifies the starting and ending characters for the match.
2596 represents the beginning and ending characters of a nested group that
2597 will be skipped over when counting starting and ending character matches.
2598 The behavior is unspecified when the first character of a
2601 except for the following:
2606 Causes the ending character to terminate the search for this pattern without
2610 Causes the ending character to be interpreted as an escape character.
2613 Causes the ending character to be interpreted as a quote character
2614 causing all characters to be ignored when looking for a match.
2617 Causes the ending character to be interpreted as a quote character
2618 causing all characters other than any escape character to be ignored
2619 when looking for a match.
2623 \f3%(\^{\^}Q"E\e\^)\fP,
2624 matches characters starting at
2628 is found not counting any
2632 that is inside a double quoted string or preceded by the escape character
2636 this pattern matches any C language string.
2638 Each sub-pattern in a composite pattern is numbered,
2639 starting at 1, by the location of the \f3(\fP within
2641 The sequence \f3\e\fP\f2n\^\fP, where \f2n\^\fP
2642 is a single digit and \f3\e\fP\f2n\^\fP comes after
2643 the \f2n\fP-th. sub-pattern,
2644 matches the same string as the sub-pattern itself.
2646 Finally a pattern can contain sub-patterns of the form
2647 \f3\(ap(\fP\f2options\^\fP\f3:\fP\f2pattern-list\^\fP\f3)\fP,
2648 where either \f2options\^\fP or \f3:\fP\f2pattern-list\^\fP
2649 can be omitted. Unlike the other compound patterns,
2650 these sub-patterns are not counted in the numbered sub-patterns.
2651 If \f2options\^\fP is present, it can consist of one or more
2657 Enable the following options. This is the default.
2660 Disable the following options.
2663 The remainder of the pattern uses extended regular expression syntax
2669 The remainder of the pattern uses
2674 The remainder of the pattern uses basic regular expression syntax
2680 The remainder of the pattern uses shell pattern syntax.
2681 This is the default.
2684 This is ignored. However, when it is the first letter and is
2685 used with file name generation, and no matches occur,
2686 the file pattern expands to the empty string.
2689 Treat the match as case insensitive.
2692 File the longest match (greedy). This is the default.
2695 Left anchor the pattern. This is the default for
2700 Right anchor the pattern. This is the default for
2705 If both \f2options\^\fP and \f3:\fP\f2pattern-list\^\fP
2706 are specified, then the options apply only to \f2pattern-list\^\fP.
2707 Otherwise, these options remain in effect until they are disabled
2708 by a subsequent \f3\(ap(\fP\f2...\^\fP\f3)\fP or at the end of
2709 the sub-pattern containing \f3\(ap(\fP\f2...\^\fP\f3)\fP.
2716 has a special meaning to the shell
2717 and causes termination of a word unless quoted.
2720 (i.e., made to stand for itself)
2727 All characters enclosed between a pair of single quote marks
2728 (\^\f3\(fm\^\(fm\fP\^)
2729 that is not preceded by a
2732 A single quote cannot appear within the single quotes.
2733 A single quoted string preceded by an unquoted
2735 is processed as an ANSI-C string
2736 except for the following:
2740 Causes the remainder of the string to be ignored.
2743 Equivalent to the escape character
2748 Equivalent to the escape character
2753 Expands to the character control-\f2x\fP.
2756 Expands to the collating element \f2name\fP.
2759 Inside double quote marks
2761 parameter and command substitution occur and
2763 quotes the characters
2771 in front of a double quoted string will be ignored
2772 in the "C" or "POSIX" locale, and may cause
2773 the string to be replaced by a locale specific string otherwise.
2778 is identical when not quoted or when used as a variable assignment value
2780 However, when used as a command argument,
2784 \f3"$1\fP\f2d\fP\f3\|$2\fP\f2d\fP\|.\|.\|.\f3"\fP,
2787 is the first character of the
2799 Inside grave quote marks
2802 quotes the characters
2807 If the grave quotes occur within double quotes, then
2809 also quotes the character
2812 The special meaning of reserved words or aliases can be removed by quoting any
2813 character of the reserved word.
2814 The recognition of function names or built-in command names listed below
2815 cannot be altered by quoting them.
2816 .SS Arithmetic Evaluation.
2817 The shell performs arithmetic evaluation for
2818 arithmetic substitution, to evaluate an arithmetic command,
2819 to evaluate an indexed array subscript,
2820 and to evaluate arguments to
2821 the built-in commands
2825 Evaluations are performed using
2826 double precision floating point
2827 arithmetic or long double precision floating point for
2828 systems that provide this data type.
2829 Floating point constants follow the ANSI-C programming language
2830 floating point conventions.
2831 Integer constants follow the ANSI-C programming language
2832 integer constant conventions although only single byte
2833 character constants are recognized and character casts
2835 In addition constants can be of the form
2836 \*(OK\f2base\f3#\^\f1\*(CK\f2n\^\fP
2839 is a decimal number between two and sixty-four
2840 representing the arithmetic base
2843 is a number in that base.
2844 The digits above 9 are represented
2845 by the lower case letters, the upper case letters,
2850 For bases less than or equal to 36, upper and lower case
2851 characters can be used interchangeably.
2853 An arithmetic expression uses the same syntax, precedence, and
2855 expression as the C language.
2856 All the C language operators
2857 that apply to floating point quantities can be used.
2858 In addition, the operator
2860 can be used for exponentiation.
2861 It has higher precedence than multiplication and is left associative.
2862 In addition, when the value of an arithmetic variable
2863 or sub-expression can be represented as a long integer,
2864 all C language integer arithmetic operations can be performed.
2865 Variables can be referenced by name within an arithmetic expression
2866 without using the parameter expansion syntax.
2867 When a variable is referenced, its value is evaluated as
2868 an arithmetic expression.
2870 Any of the following math library functions that are in the C math library
2871 can be used within an arithmetic expression:
2875 .if n abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmod hypot ilogb int isinf isnan j0 j1 jn lgamma log log2 logb nearbyint nextafter nexttoward pow remainder rint round sin sinh sqrt tan tanh tgamma trunc y0 y1 yn
2876 .if t abs acos acosh asin asinh atan atan2 atanh cbrt copysign cos cosh erf erfc exp exp2 expm1 fabs fdim finite floor fma fmax fmod j0 j1 jn hypot ilogb int isinf isnan lgamma log log2 logb nearbyint nextafter nexttoward pow rint round sin sinh sqrt tan tanh tgamma trunc y0 y1 yn
2879 An internal representation of a
2881 as a double precision floating point can be specified with the
2882 \f3\-E\fP \*(OK\f2n\^\fP\*(CK,
2883 \f3\-F\fP \*(OK\f2n\^\fP\*(CK,
2885 \f3\-X\fP \*(OK\f2n\^\fP\*(CK
2888 special built-in command.
2891 option causes the expansion of the value to be represented using
2892 scientific notation when it is expanded.
2893 The optional option argument
2895 defines the number of significant figures.
2898 option causes the expansion to be represented as a floating decimal number
2899 when it is expanded.
2902 option cause the expansion to be represented using the
2904 format defined by ISO C-99.
2905 The optional option argument
2907 defines the number of places after the decimal (or radix) point in this case.
2909 An internal integer representation of a
2911 can be specified with the
2912 \f3\-i\fP \*(OK\f2n\^\fP\*(CK
2915 special built-in command.
2916 The optional option argument
2918 specifies an arithmetic base to be used when expanding the variable.
2919 If you do not specify an arithmetic base,
2920 base 10 will be used.
2922 Arithmetic evaluation is performed on the value of each
2923 assignment to a variable with the
2930 Assigning a floating point number to a
2931 variable whose type is an integer causes the fractional
2932 part to be truncated.
2935 When used interactively,
2936 the shell prompts with the value of
2939 after expanding it for parameter expansion, command substitution, and
2940 arithmetic substitution,
2941 before reading a command.
2942 In addition, each single
2944 in the prompt is replaced by the command number.
2947 is required to place
2950 If at any time a new-line is typed and further input is needed
2951 to complete a command, then the secondary prompt
2955 .SS Conditional Expressions.
2957 .I "conditional expression"
2960 compound command to test attributes of files and to compare
2962 Field splitting and file name generation are
2963 not performed on the words between
2967 Each expression can be constructed from one or more
2968 of the following unary or binary expressions:
2976 \f3\-a\fP \f2file\fP
2977 Same as \f3\-e\fP below.
2980 \f3\-b\fP \f2file\fP
2983 exists and is a block special file.
2985 \f3\-c\fP \f2file\fP
2988 exists and is a character special file.
2990 \f3\-d\fP \f2file\fP
2993 exists and is a directory.
2995 \f3\-e\fP \f2file\fP
3000 \f3\-f\fP \f2file\fP
3003 exists and is an ordinary file.
3005 \f3\-g\fP \f2file\fP
3008 exists and it has its setgid bit set.
3010 \f3\-k\fP \f2file\fP
3013 exists and it has its sticky bit set.
3015 \f3\-n\fP \f2string\fP
3020 \f3\-o\fP \f3?\fP\f2option\fP
3021 True, if option named
3023 is a valid option name.
3025 \f3\-o\fP \f2option\fP
3026 True, if option named
3030 \f3\-p\fP \f2file\fP
3033 exists and is a fifo special file or a pipe.
3035 \f3\-r\fP \f2file\fP
3038 exists and is readable by current process.
3040 \f3\-s\fP \f2file\fP
3043 exists and has size greater than zero.
3045 \f3\-t\fP \f2fildes\fP
3046 True, if file descriptor number
3048 is open and associated with a terminal device.
3050 \f3\-u\fP \f2file\fP
3053 exists and it has its setuid bit set.
3055 \f3\-w\fP \f2file\fP
3058 exists and is writable by current process.
3060 \f3\-x\fP \f2file\fP
3063 exists and is executable by current process.
3066 exists and is a directory, then true if the current process
3067 has permission to search in the directory.
3069 \f3\-z\fP \f2string\fP
3074 \f3\-L\fP \f2file\fP
3077 exists and is a symbolic link.
3079 \f3\-h\fP \f2file\fP
3082 exists and is a symbolic link.
3084 \f3\-N\fP \f2file\fP
3087 exists and the modification time is greater than the last access time.
3089 \f3\-O\fP \f2file\fP
3092 exists and is owned by the effective user id of this process.
3094 \f3\-G\fP \f2file\fP
3097 exists and its group matches the effective group id of this process.
3099 \f3\-S\fP \f2file\fP
3102 exists and is a socket.
3104 \f2file1\fP \f3\-nt\fP \f2file2\fP
3114 \f2file1\fP \f3\-ot\fP \f2file2\fP
3124 \f2file1\fP \f3\-ef\fP \f2file2\fP
3129 exist and refer to the same file.
3131 \f2string\fP \f3==\fP \f2pattern\fP
3138 can be quoted to cause it to be matched as a string.
3139 With a successful match to a pattern, the
3141 array variable will contain the match and sub-pattern matches.
3143 \f2string\fP \f3=\fP \f2pattern\fP
3144 Same as \f3==\fP above, but is obsolete.
3146 \f2string\fP \f3!=\fP \f2pattern\fP
3157 array variable will contain the match and sub-pattern matches.
3159 \f2string\fP \f3=\(ap\fP \f2ere\fP
3166 is an extended regular expression.
3168 \f2string1\fP \f3<\fP \f2string2\fP
3173 based on ASCII value of their characters.
3175 \f2string1\fP \f3>\fP \f2string2\fP
3180 based on ASCII value of their characters.
3182 The following obsolete arithmetic comparisons are also permitted:
3185 \f2exp1\fP \f3\-eq\fP \f2exp2\fP
3191 \f2exp1\fP \f3\-ne\fP \f2exp2\fP
3197 \f2exp1\fP \f3\-lt\fP \f2exp2\fP
3203 \f2exp1\fP \f3\-gt\fP \f2exp2\fP
3209 \f2exp1\fP \f3\-le\fP \f2exp2\fP
3212 is less than or equal to
3215 \f2exp1\fP \f3\-ge\fP \f2exp2\fP
3218 is greater than or equal to
3222 In each of the above expressions, if
3225 \f3/dev/fd/\fP\f2n\fP,
3229 then the test is applied to the open file whose
3230 descriptor number is
3233 A compound expression can be constructed from these primitives by
3234 using any of the following, listed in decreasing order of precedence.
3237 \f3(\fP\f2expression\fP\f3)\fP
3241 Used to group expressions.
3243 \f3!\fP \f2expression\fP
3248 \f2expression1\fP \f3&&\fP \f2expression2\fP
3255 \f2expression1\fP \f3\(bv\(bv\fP \f2expression2\fP
3263 Before a command is executed, its input and output
3264 may be redirected using a special notation interpreted by the shell.
3265 The following may appear anywhere in a simple-command
3266 or may precede or follow a
3270 passed on to the invoked command.
3271 Command substitution, parameter expansion,
3272 and arithmetic substitution occur before
3276 is used except as noted below.
3277 File name generation
3278 occurs only if the shell is interactive and
3279 the pattern matches a single file.
3280 Field splitting is not performed.
3282 In each of the following redirections, if
3285 \f3/dev/sctp/\fP\f2host\fP\f3/\fP\f2port\fP,
3286 \f3/dev/tcp/\fP\f2host\fP\f3/\fP\f2port\fP,
3288 \f3/dev/udp/\fP\f2host\fP\f3/\fP\f2port\fP,
3291 is a hostname or host address,
3294 is a service given by name or an integer port number,
3295 then the redirection attempts to make a
3296 \f3tcp\fP, \f3sctp\fP or \f3udp\fP connection to the corresponding
3299 No intervening space is allowed between the characters of redirection operators.
3304 as standard input (file descriptor 0).
3309 as standard output (file descriptor 1).
3310 If the file does not exist then it is created.
3311 If the file exists, and the
3314 this causes an error;
3315 otherwise, it is truncated to zero length.
3320 except that it overrides the
3325 Write output to a temporary file. If the command completes
3326 successfully rename it to
3328 otherwise, delete the temporary file.
3330 cannot be used with the
3338 If the file exists, then output is appended to it (by first seeking to the end-of-file);
3339 otherwise, the file is created.
3344 for reading and writing
3350 except that if the command completes successfully,
3352 is truncated to the offset at command completion.
3354 cannot be used with the
3358 \f3<<\fP\*(OK\f3\-\fP\*(CK\f2word\fP
3359 The shell input is read up to a line that is the same as
3361 after any quoting has been removed,
3362 or to an end-of-file.
3363 No parameter substitution, command substitution, arithmetic substitution or
3364 file name generation is performed on
3366 The resulting document,
3373 is quoted, then no interpretation
3374 is placed upon the characters of the document;
3375 otherwise, parameter expansion, command substitution, and arithmetic
3381 must be used to quote the characters
3389 then all leading tabs are stripped from
3391 and from the document.
3396 then leading spaces and tabs will be stripped off the first
3397 line of the document and up to an equivalent indentation will
3398 be stripped from the remaining lines and from
3400 A tab stop is assumed to occur at every 8 columns for the
3401 purposes of determining the indentation.
3404 A short form of here document in which \f2word\fP becomes the
3405 contents of the here-document after any
3406 parameter expansion, command substitution, and arithmetic
3410 The standard input is duplicated from file descriptor
3414 Similarly for the standard output using
3418 The file descriptor given by
3420 is moved to standard input.
3421 Similarly for the standard output using
3422 \f3>&\^\f2digit\f3\-\fR.
3425 The standard input is closed.
3426 Similarly for the standard output using
3430 The input from the co-process is moved to standard input.
3433 The output to the co-process is moved to standard output.
3435 .BI <# \^\^\^ (( expr ))
3436 Evaluate arithmetic expression
3438 and position file descriptor 0
3439 to the resulting value
3440 bytes from the start of the file.
3445 evaluate to the current offset and end-of-file offset
3446 respectively when evaluating
3449 .BI ># \^\^\^ (( offset ))
3452 except applies to file descriptor 1.
3455 Seeks forward to the beginning of the next line containing
3461 except that the portion of the file that is skipped is copied to
3464 If one of the above is preceded by a digit,
3465 with no intervening space, then the
3466 file descriptor number referred to is that specified
3468 (instead of the default 0 or 1).
3469 If one of the above, other than
3478 with no intervening space,
3479 then a file descriptor number > 10
3481 the shell and stored in the variable
3494 defines the file descriptor to close or position.
3498 \fB\&.\|.\|. \|2>&1\fR
3501 means file descriptor 2 is to be opened
3502 for writing as a duplicate
3503 of file descriptor 1 and
3509 means open file named
3511 for reading and store
3512 the file descriptor number in variable
3515 The order in which redirections are specified is significant.
3516 The shell evaluates each redirection in terms of the
3517 .RI ( "file descriptor" ", " file )
3518 association at the time of evaluation.
3522 \fB\&.\|.\|. \|1>\f2fname\^\fP 2>&1\fR
3525 first associates file descriptor 1 with file
3527 It then associates file descriptor 2 with the file associated with file
3530 If the order of redirections were reversed, file descriptor 2 would be associated
3531 with the terminal (assuming file descriptor 1 had been) and then file descriptor
3532 1 would be associated with file
3535 If a command is followed by
3537 and job control is not active,
3538 then the default standard input
3542 Otherwise, the environment for the execution of a command contains the
3543 file descriptors of the invoking shell as modified by
3544 input/output specifications.
3550 is a list of name-value pairs that is passed to
3551 an executed program in the same way as a normal argument list.
3554 and the values are character strings.
3555 The shell interacts with the environment in several ways.
3556 On invocation, the shell scans the environment
3559 for each name found,
3560 giving it the corresponding value and attributes and marking it
3562 Executed commands inherit the environment.
3563 If the user modifies the values of these
3565 or creates new ones,
3570 commands, they become part of the
3572 The environment seen by any executed command is thus composed
3573 of any name-value pairs originally inherited by the shell,
3574 whose values may be modified by the current shell,
3576 which must be noted in
3582 The environment for any
3585 may be augmented by prefixing it with one or more variable assignments.
3586 A variable assignment argument is a word of the form
3587 .IR identifier=value .
3591 \fB\s-1TERM\s+1=450 \|cmd \|args\fR and
3593 \fB(export \|\s-1TERM\s+1; \|\s-1TERM\s+1=450; \|cmd \|args)\fR
3596 are equivalent (as far as the above execution of
3598 is concerned except for special built-in commands listed below \-
3600 preceded with a dagger).
3606 variable assignment arguments are placed in the environment,
3607 even if they occur after the command name.
3623 This feature is intended for use with scripts written
3624 for early versions of the shell and its use in new scripts
3625 is strongly discouraged.
3626 It is likely to disappear someday.
3629 For historical reasons, there are two
3630 ways to define functions,
3637 syntax, described in the
3640 Shell functions are read in and stored internally.
3641 Alias names are resolved when the function is read.
3642 Functions are executed like commands with the arguments
3643 passed as positional parameters.
3648 Functions defined by the
3651 syntax and called by name execute in the same process as the caller and
3653 and present working directory with the
3655 Traps caught by the caller are reset to their default action
3656 inside the function.
3657 A trap condition that is not caught or ignored by the
3658 function causes the function to terminate and the condition
3659 to be passed on to the caller.
3663 set inside a function
3667 after the function completes.
3669 variables are shared between the calling program
3674 special built-in command used within a function
3675 defines local variables whose scope includes
3676 the current function.
3677 They can be passed to functions that they call in the
3678 variable assignment list that precedes the call or as arguments
3679 passed as name references.
3680 Errors within functions return control to the caller.
3682 Functions defined with the
3684 syntax and functions defined with the
3687 syntax that are invoked with the \f3\s+2.\s-2\fP
3689 are executed in the caller's
3690 environment and share all variables
3691 and traps with the caller.
3692 Errors within these function executions cause the script that contains
3695 The special built-in command
3698 from function calls.
3701 can be listed with the
3707 special built-in command.
3708 The text of functions, when available, will also
3711 Functions can be undefined with the
3715 special built-in command.
3717 Ordinarily, functions are unset when the shell executes a shell script.
3718 Functions that need to be defined across separate
3719 invocations of the shell should
3720 be placed in a directory and the
3724 variable should contain the name of this directory.
3731 .SS Discipline Functions.
3732 Each variable can have zero or more discipline functions
3734 The shell initially understands the discipline names \f3get\fP,
3735 \f3set\fP, \f3append\fP, and \f3unset\fP but can be added
3736 when defining new types. On most systems
3737 others can be added at run time via the
3738 C programming interface extension provided by the
3741 If the \f3get\fP discipline is defined for a variable, it is invoked
3742 whenever the given variable is referenced.
3743 If the variable \f3.sh.value\fP is assigned a value inside
3744 the discipline function, the referenced variable will evaluate
3745 to this value instead.
3746 If the \f3set\fP discipline is defined for a variable, it is invoked
3747 whenever the given variable is assigned a value.
3748 If the \f3append\fP discipline is defined for a variable, it is invoked
3749 whenever a value is appended to the given variable.
3750 The variable \f3.sh.value\fP is given the value
3751 of the variable before invoking the discipline, and
3752 the variable will be assigned the value of \f3.sh.value\fP
3753 after the discipline completes.
3754 If \f3.sh.value\fP is unset inside the discipline, then
3755 that value is unchanged.
3756 If the \f3unset\fP discipline is defined for a variable, it is invoked
3757 whenever the given variable is unset.
3758 The variable will not be unset unless it is unset explicitly
3759 from within this discipline function.
3763 contains the name of the variable for which the discipline function is called,
3765 is the subscript of the variable, and
3767 will contain the value being assigned inside the
3769 discipline function.
3772 is a reference to the variable including the subscript if any.
3773 For the \f3set\fP discipline,
3776 will change the value that gets assigned.
3777 Finally, the expansion \f3${\fP\f2var\^\fP\f3.\fP\f2name\^\fP\f3}\fP,
3778 when \f2name\^\fP is the name of a discipline, and there is
3779 no variable of this name, is equivalent to the command substitution
3780 \f3${ \fP\f2var\^\fP\f3.\fP\f2name\^\fP\f3;}\fP.
3783 Typed variables provide a way to create data structure and objects.
3784 A type can be defined either by a shared library, by the
3786 built-in command described below, or by using the new
3795 the type name, specified as an option argument to
3797 is set with a compound variable assignment that defines the type.
3798 Function definitions can appear inside the compound variable
3799 assignment and these become discipline functions for this type and
3800 can be invoked or redefined by each instance of the type.
3803 is treated specially. It is invoked for each instance of
3804 the type that is created but is not inherited and cannot be
3805 redefined for each instance.
3807 When a type is defined a special built-in command of that name
3808 is added. These built-ins are declaration commands and follow the
3809 same expansion rules as all the special built-in commands defined
3810 below that are preceded by \(dg\(dg. These commands can subsequently
3811 be used inside further type definitions. The man page for these commands can
3812 be generated by using the
3814 option or any of the other
3816 options described with
3827 are permitted with each of these new built-ins.
3829 An instance of a type is created by invoking the type name
3830 followed by one or more instance names.
3831 Each instance of the type is initialized with a copy of the sub-variables
3832 except for sub-variables that are defined with the
3834 option. Variables defined with the
3836 are shared by all instances of the type.
3837 Each instance can change the value of any sub-variable and can also
3838 define new discipline functions of the same names
3839 as those defined by the type definition as well as any
3840 standard discipline names.
3841 No additional sub-variables can be defined for any instance.
3843 When defining a type,
3844 if the value of a sub-variable is not set and the
3846 attribute is specified, it causes the sub-variable
3847 to be a required sub-variable.
3848 Whenever an instance of a type is created, all required sub-variables
3850 These sub-variables become readonly in each instance.
3854 is invoked on a sub-variable within a type,
3857 attribute has not been specified for this field,
3858 the value is reset to the default value associative with
3862 on a type instance not contained within another type deletes
3863 all sub-variables and the variable itself.
3865 A type definition can be derived from another type definition
3866 by defining the first sub-variable name as
3868 and defining its type as the base type.
3869 Any remaining definitions will be additions and modifications
3870 that apply to the new type.
3871 If the new type name is the same is that of the base type,
3872 the type will be replaced and the original type will
3873 no longer be accessible.
3881 command is turned on,
3882 an interactive shell associates a \fIjob\fR with each pipeline.
3884 a table of current jobs, printed by the
3886 command, and assigns them small integer numbers.
3887 When a job is started asynchronously with
3889 the shell prints a line which looks
3895 indicating that the job which was started asynchronously was job number
3896 1 and had one (top-level) process, whose process id was 1234.
3898 This paragraph and the next require features that are
3899 not in all versions of UNIX and may not apply.
3900 If you are running a job and wish to do something else you may hit the key
3901 \fB^Z\fR (control-Z) which sends a STOP signal to the current job.
3902 The shell will then normally indicate that the job has been `Stopped',
3903 and print another prompt.
3904 You can then manipulate the state of this job,
3905 putting it in the background with the
3907 command, or run some other
3908 commands and then eventually bring the job back into the foreground with
3909 the foreground command
3911 A \fB^Z\fR takes effect immediately and
3912 is like an interrupt in that pending output and unread input are discarded
3915 A job being run in the background will stop if it tries to read
3917 Background jobs are normally allowed to produce output,
3918 but this can be disabled by giving the command
3921 tty option, then background jobs will stop when they try to produce
3922 output like they do when they try to read input.
3924 There are several ways to refer to jobs in the shell.
3925 A job can be referred to by the process id of any process of the job
3926 or by one of the following:
3930 The job with the given number.
3933 Any job whose command line begins with
3937 Any job whose command line contains
3951 The shell learns immediately whenever a process changes state.
3952 It normally informs you whenever a job becomes blocked so that
3953 no further progress is possible, but only just before it prints
3955 This is done so that it does not otherwise disturb your work.
3961 the shell to print these job change messages
3962 as soon as they occur.
3966 option is on, each background job that completes
3967 triggers any trap set for
3970 When you try to leave the shell while jobs are running or stopped, you will
3971 be warned that `You have stopped(running) jobs.'
3974 command to see what they are.
3975 If you immediately try to
3976 exit again, the shell will not warn you a second time, and the stopped
3977 jobs will be terminated.
3978 When a login shell receives a HUP signal, it sends
3979 a HUP signal to each job that has not been disowned with the
3981 built-in command described below.
3983 The \s-1INT\s+1 and \s-1QUIT\s+1 signals for an invoked
3984 command are ignored if the command is followed by
3988 option is not active.
3989 Otherwise, signals have the values
3990 inherited by the shell from its parent
3994 built-in command below).
3996 Each time a command is read, the above substitutions
3998 If the command name matches one
4000 .I "Special Built-in Commands\^"
4002 it is executed within the
4003 current shell process.
4004 Next, the command name is checked to see if
4005 it matches a user defined function.
4007 the positional parameters are saved
4008 and then reset to the arguments of the
4011 A function is also executed in the
4012 current shell process.
4015 completes or issues a
4017 the positional parameter list is restored.
4018 For functions defined with the
4025 within the function is executed.
4028 is the value of the last command executed.
4029 If a command name is not a
4030 .I "special built-in command\^"
4033 but it is one of the built-in commands listed below,
4034 it is executed in the current shell process.
4039 defines the search path for
4040 the directory containing the command.
4041 Alternative directory names are separated by
4049 and the current directory
4051 The current directory can be specified by
4052 two or more adjacent colons, or by a colon
4053 at the beginning or end of the path list.
4054 If the command name contains a \f3/\fP, then the search path
4056 Otherwise, each directory in the path is
4057 searched for an executable file
4059 that is not a directory.
4060 If found, and if the shell
4061 determines that there is a built-in version
4062 of a command corresponding to a given pathname,
4063 this built-in is invoked in the current process.
4064 If found, and this directory is also contained in the value of the
4068 then this file is loaded into the current shell environment
4069 as if it were the argument to the \fB.\fP command
4070 except that only preset aliases are expanded,
4071 and a function of the given name is executed
4073 If not found, and the file
4075 is found, and this file contains a line of the form
4080 existing directory, and this directory contains
4081 a file of the given name,
4082 then this file is loaded into the current shell environment
4083 as if it were the argument to the \fB.\fP special built-in command
4084 and a function of the given name is executed.
4085 Otherwise, if found,
4086 a process is created and
4087 an attempt is made to execute the command via
4090 When an executable is found, the directory where it is found
4091 in is searched for a file named
4093 If this file is found and it contains a line of the form
4094 .BI BUILTIN_LIB= value\^
4095 , then the library named by
4097 will be searched for as if it were an option argument to
4099 and if it contains a built-in of the specified name
4100 this will be executed instead of a command by this name.
4101 Otherwise, if this file is found and it contains a line of the form
4102 .IB name\^ = value\^
4103 in the first or second line, then the environment variable
4105 is modified by prepending the directory specified by
4107 to the directory list.
4110 is not an absolute directory, then it
4111 specifies a directory relative to the directory that the
4112 executable was found.
4113 If the environment variable
4115 does not already exist it will be added to the environment
4116 list for the specified command.
4118 If the file has execute permission but is not an
4121 it is assumed to be a file containing shell commands.
4122 A separate shell is spawned to read it.
4123 All non-exported variables are removed in this case.
4124 If the shell command
4125 file doesn't have read permission,
4130 bits are set on the file,
4131 then the shell executes an agent whose job it is to
4132 set up the permissions and execute the shell with the
4133 shell command file passed down as an open file.
4134 A parenthesized command is executed in
4135 a sub-shell without removing non-exported variables.
4136 .SS Command Re-entry.
4137 The text of the last
4142 commands entered from a terminal device
4147 .B \s-1$HOME\s+1/.sh_history
4153 or if the file it names is not writable.
4154 A shell can access the commands of
4157 shells which use the same named
4160 The built-in command
4163 edit a portion of this file.
4164 The portion of the file to be edited or listed can be selected by
4165 number or by giving the first character or
4166 characters of the command.
4167 A single command or range of commands can be specified.
4168 If you do not specify an editor program as
4171 then the value of the variable
4178 is unset, the obsolete variable
4185 is not defined, then
4188 The edited command(s) is printed and re-executed upon
4189 leaving the editor unless you quit without writing.
4193 (and in obsolete versions, the editor name
4195 is used to skip the editing phase and
4196 to re-execute the command.
4197 In this case a substitution parameter of the form
4198 \f2old\fP\f3=\fP\f2new\fP
4199 can be used to modify the command before execution.
4200 For example, with the preset alias
4203 .BR "\(fmhist \-s\(fm" ,
4205 `\f3r bad=good c\fP'
4206 will re-execute the most recent command which starts with the letter
4208 replacing the first occurrence of the string
4212 .SS In-line Editing Options.
4213 Normally, each command line entered from a terminal device is simply
4214 typed followed by a \f3new-line\fP (`RETURN' or `LINE\ FEED').
4220 option is active, the user can edit the command line.
4221 To be in either of these edit modes
4225 An editing option is automatically selected each time the
4231 variable is assigned a value ending in either of these
4234 The editing features require that the user's terminal
4235 accept `RETURN' as carriage return without line feed
4236 and that a space (`\ ') must overwrite the current character on
4242 the editing modes implement a concept where the user is looking through a
4243 window at the current line.
4244 The window width is the value of
4247 if it is defined, otherwise 80.
4248 If the window width is too small to display the prompt and leave
4249 at least 8 columns to enter input, the prompt is truncated from the
4251 If the line is longer than the window width minus two, a mark is
4252 displayed at the end of the window to notify the user.
4253 As the cursor moves and reaches the window boundaries the window will be
4254 centered about the cursor.
4258 if the line extends on the
4259 right (left, both) side(s) of the window.
4261 The search commands in each edit mode provide access to the history file.
4262 Only strings are matched, not patterns, although a leading
4264 in the string restricts the match
4265 to begin at the first character in the line.
4267 Each of the edit modes has an operation to list the files
4268 or commands that match a partially entered word.
4269 When applied to the first word on the line,
4270 or the first word after a
4276 and the word does not begin with
4280 the list of aliases, functions, and executable commands
4284 variable that could match the partial word is displayed.
4285 Otherwise, the list of files that match the given
4287 If the partially entered word does not contain any
4288 file expansion characters, a
4290 is appended before generating these lists.
4291 After displaying the generated list, the input line
4293 These operations are called command name listing and file name listing,
4295 There are additional operations, referred to as command name
4296 completion and file name completion, which compute the list
4297 of matching commands or files, but instead of printing the list,
4299 the current word with a complete or partial match.
4300 For file name completion,
4301 if the match is unique, a
4303 is appended if the file is a directory and a space is
4304 appended if the file is not a directory.
4305 Otherwise, the longest common prefix for all the matching
4306 files replaces the word.
4307 For command name completion, only the portion of the file names
4310 are used to find the longest command prefix.
4311 If only a single name matches this prefix, then the
4312 word is replaced with the command name followed by a space.
4315 for completion that does not yield a unique match,
4318 will provide a numbered list of matching alternatives.
4319 A specific selection can be made by entering the
4320 selection number followed by a
4326 trap can be used to intercept keys as they are typed
4327 and change the characters that are actually seen by
4329 This trap is executed after each character
4330 (or sequence of characters when the first character is ESC)
4331 is entered while reading from a terminal.
4334 contains the character or character sequence which
4336 Changing the value of
4338 in the trap action causes the shell to behave as if the
4339 new value were entered from the keyboard rather than
4344 is set to the input column number of the cursor at the time
4352 insert mode (see below) and is null otherwise.
4355 to a value assigned to
4357 it will cause the shell
4358 to change to control mode if it is not already in this mode.
4360 This trap is not invoked for characters entered as arguments to
4361 editing directives, or while reading input for a character search.
4362 .SS Emacs Editing Mode.
4363 This mode is entered by enabling either the
4368 The only difference between these two modes is the way
4372 moves the cursor to the point needing correction and
4373 then inserts or deletes characters or words as needed.
4374 All the editing commands are control characters or escape
4376 The notation for control characters is caret
4382 is the notation for control
4384 This is entered by depressing `f' while holding down the
4385 `CTRL' (control) key.
4391 indicates the DEL (delete) key.)
4393 The notation for escape sequences is
4400 is entered by depressing ESC
4405 would be the notation for ESC followed by `SHIFT' (capital) `F'.)
4408 operate from any place on the line
4409 (not just at the beginning).
4410 Neither the `RETURN' nor the `LINE FEED' key is
4411 entered after edit commands except when noted.
4416 Move cursor forward (right) one character.
4420 Move cursor forward (right) one character.
4424 Move cursor forward one word.
4427 editor's idea of a word is a string of characters
4428 consisting of only letters, digits and underscores.)
4432 Move cursor backward (left) one character.
4436 Move cursor backward (left) one character.
4440 Move cursor backward one word.
4444 Move cursor to start of line.
4448 Move cursor to start of line.
4452 Move cursor to end of line.
4456 Move cursor to end of line.
4460 Move cursor forward to character
4466 Move cursor backward to character
4472 Interchange the cursor and mark.
4476 (User defined erase character as defined
4483 Delete previous character.
4487 (User defined literal next character as defined
4494 Removes the next character's
4495 editing features (if any).
4499 Delete current character.
4503 Delete current word.
4507 (Meta-backspace) Delete previous word.
4511 Delete previous word.
4515 (Meta-DEL) Delete previous word (if your interrupt character is
4517 (DEL, the default) then this command will not work).
4521 Transpose current character with previous character
4522 and advance the cursor
4526 Transpose two previous characters in
4532 Capitalize current character.
4536 Capitalize current word.
4540 Change the current word to lower case.
4544 Delete from the cursor to the end of the line.
4545 If preceded by a numerical parameter whose value is less than the
4546 current cursor position, then delete from given position
4548 If preceded by a numerical parameter whose value is greater than the
4549 current cursor position, then delete from cursor up to
4550 given cursor position.
4554 Kill from the cursor to the mark.
4558 Push the region from the cursor to the mark on the stack.
4562 (User defined kill character as defined
4563 by the stty command, usually
4567 Kill the entire current line.
4570 characters are entered in succession, all
4571 kill characters from then on cause a line feed
4572 (useful when using paper terminals).
4576 Restore last item removed from line. (Yank item back to the line.)
4580 Line feed and print current line.
4588 (Null character) Set mark.
4592 (Meta space) Set mark.
4596 (New\ line) Execute the current line.
4600 (Return) Execute the current line.
4604 End-of-file character,
4607 is processed as an End-of-file only
4608 if the current line is null.
4612 Fetch previous command.
4616 the previous command back in time is accessed.
4617 Moves back one line when not on the first line of a multi-line command.
4621 If the cursor is at the end of the line, it is equivalent to
4625 set to the contents of the current line.
4632 Fetch the least recent (oldest) history line.
4636 Fetch the most recent (youngest) history line.
4640 Fetch next command line.
4644 the next command line forward in time is accessed.
4653 Reverse search history for a previous command line containing
4655 If a parameter of zero is given, the search is forward.
4657 is terminated by a `RETURN' or `NEW\ LINE'.
4658 If string is preceded by a
4660 the matched line must begin with
4665 then the next command line containing the most recent
4668 In this case a parameter of zero
4669 reverses the direction of the search.
4673 Operate \- Execute the current line and fetch
4674 the next line relative to current line from the
4679 (Escape) Define numeric parameter, the digits
4680 are taken as a parameter to the next command.
4681 The commands that accept a parameter are
4707 Soft-key \- Your alias list is searched for an
4710 and if an alias of this name is defined, its
4711 value will be inserted on the input queue.
4714 must not be one of the above meta-functions.
4718 Soft-key \- Your alias list is searched for an
4721 and if an alias of this name is defined, its
4722 value will be inserted on the input queue.
4723 This can be used to program function keys on many terminals.
4727 The last word of the previous command is inserted
4729 If preceded by a numeric parameter, the value
4730 of this parameter determines which word to insert rather than
4740 Attempt file name generation on the current word.
4741 An asterisk is appended if the word doesn't match any file
4742 or contain any special
4747 Command or file name completion as described above.
4751 Attempts command or file name completion as described above.
4752 If a partial completion occurs, repeating this will
4756 If no match is found or entered after
4764 If not preceded by a numeric parameter,
4765 it generates the list of matching commands or
4766 file names as described above.
4767 Otherwise, the word under the cursor is replaced by
4768 the item corresponding to the value of the numeric parameter
4769 from the most recently generated command or file list.
4770 If the cursor is not on a word, it is inserted instead.
4774 Multiply parameter of next command by 4.
4778 Escape next character.
4779 Editing characters, the user's erase, kill and
4784 in a command line or in a search string if preceded by a
4788 removes the next character's
4789 editing features (if any).
4793 Display version of the shell.
4797 If the line does not begin with a
4802 at the beginning of the line
4803 and after each new-line,
4804 and the line is entered.
4805 This causes a comment to be inserted in the history file.
4806 If the line begins with a
4812 after each new-line is also deleted.
4814 .SS Vi Editing Mode.
4815 There are two typing modes.
4816 Initially, when you enter a command you are in the
4819 To edit, the user enters
4823 and moves the cursor to the point needing correction and
4824 then inserts or deletes characters or words as needed.
4825 Most control commands accept an optional repeat
4827 prior to the command.
4831 mode on most systems,
4832 canonical processing is initially enabled and the
4833 command will be echoed again if the speed is 1200 baud or greater and it
4834 contains any control characters or less than one second has elapsed
4835 since the prompt was printed.
4836 The ESC character terminates canonical processing for the remainder of the command
4837 and the user can then modify the command line.
4838 This scheme has the advantages of canonical processing with the type-ahead
4839 echoing of raw mode.
4843 is also set, the terminal will always have canonical processing
4845 This mode is implicit for systems that do not support two
4846 alternate end of line delimiters,
4847 and may be helpful for certain terminals.
4848 .SS "\ \ \ \ \ Input Edit Commands"
4851 By default the editor is in input mode.
4855 (User defined erase character as defined
4856 by the stty command, usually
4860 Delete previous character.
4863 Delete the previous blank separated word.
4864 On some systems the \f3viraw\fP option
4865 may be required for this to work.
4868 As the first character of the line causes
4869 the shell to terminate unless the \f3ignoreeof\fP
4871 Otherwise this character is ignored.
4874 (User defined literal next character as defined
4880 Removes the next character's
4881 editing features (if any).
4882 On some systems the \f3viraw\fP option
4883 may be required for this to work.
4893 Attempts command or file name completion as described above
4894 and returns to input mode.
4895 If a partial completion occurs, repeating this will
4898 were entered from control mode.
4899 If no match is found or entered after
4905 .SS "\ \ \ \ \ Motion Edit Commands"
4907 These commands will move the cursor.
4909 [\f2count\fP]\f3l\fP
4910 Cursor forward (right) one character.
4912 [\f2count\fP]\f3[C\fP
4913 Cursor forward (right) one character.
4915 [\f2count\fP]\f3w\fP
4916 Cursor forward one alpha-numeric word.
4918 [\f2count\fP]\f3W\fP
4919 Cursor to the beginning of the next word that follows a blank.
4921 [\f2count\fP]\f3e\fP
4922 Cursor to end of word.
4924 [\f2count\fP]\f3E\fP
4925 Cursor to end of the current blank delimited word.
4927 [\f2count\fP]\f3h\fP
4928 Cursor backward (left) one character.
4930 [\f2count\fP]\f3[D\fP
4931 Cursor backward (left) one character.
4933 [\f2count\fP]\f3b\fP
4934 Cursor backward one word.
4936 [\f2count\fP]\f3B\fP
4937 Cursor to preceding blank separated word.
4939 [\f2count\fP]\f3\(bv\fP
4943 [\f2count\fP]\f3f\fP\f2c\fP
4944 Find the next character \fIc\fP in the current line.
4946 [\f2count\fP]\f3F\fP\f2c\fP
4947 Find the previous character \fIc\fP in the current line.
4949 [\f2count\fP]\f3t\fP\f2c\fP
4955 [\f2count\fP]\f3T\fP\f2c\fP
4961 [\f2count\fP]\f3;\fP
4965 the last single character find command,
4972 [\f2count\fP]\f3,\fP
4973 Reverses the last single character find command
4978 Cursor to start of line.
4981 Cursor to start of line.
4984 Cursor to first non-blank character in line.
4987 Cursor to end of line.
4990 Cursor to end of line.
5001 If cursor is not on one of the above characters,
5002 the remainder of the line is searched for the first
5003 occurrence of one of the above characters first.
5005 .SS "\ \ \ \ \ Search Edit Commands"
5007 These commands access your command history.
5009 [\f2count\fP]\f3k\fP
5010 Fetch previous command.
5014 the previous command back in time is accessed.
5016 [\f2count\fP]\f3\-\fP
5020 [\f2count\fP]\f3[A\fP
5021 If cursor is at the end of the line it is equivalent to
5025 set to the contents of the current line.
5026 Otherwise, it is equivalent to
5029 [\f2count\fP]\f3j\fP
5034 the next command forward in time is accessed.
5036 [\f2count\fP]\f3+\fP
5040 [\f2count\fP]\f3[B\fP
5044 [\f2count\fP]\f3G\fP
5048 The default is the least recent history command.
5051 Search backward through history for a previous command containing
5054 is terminated by a `RETURN' or `NEW\ LINE'.
5055 If string is preceded by a
5057 the matched line must begin with
5059 If \fIstring\fP is null, the previous string will be used.
5064 except that search will be in the forward direction.
5067 Search for next match of the last pattern to
5074 Search for next match of the last pattern to
5078 but in reverse direction.
5080 .SS "\ \ \ \ \ Text Modification Edit Commands"
5082 These commands will modify the line.
5085 Enter input mode and enter text after the current character.
5088 Append text to the end of the line.
5092 [\f2count\fP]\f3c\fP\f2motion\fP
5094 \f3c\fP[\f2count\fP]\f2motion\fP
5095 Delete current character through the character that
5097 would move the cursor to and enter input mode.
5100 the entire line will be deleted and
5104 Delete the current character through the end of line and enter input mode.
5112 [\f2count\fP]\f3s\fP
5113 Replace characters under the cursor in input mode.
5116 Delete the current character through the end of line.
5120 [\f2count\fP]\f3d\fP\f2motion\fP
5122 \f3d\fP[\f2count\fP]\f2motion\fP
5123 Delete current character through the character that
5128 the entire line will be deleted.
5131 Enter input mode and insert text before the current character.
5134 Insert text before the beginning of the line.
5138 [\f2count\fP]\f3P\fP
5139 Place the previous text modification before the cursor.
5141 [\f2count\fP]\f3p\fP
5142 Place the previous text modification after the cursor.
5145 Enter input mode and
5146 replace characters on the screen with characters you type overlay fashion.
5148 [\f2count\fP]\f3r\fP\f2c\fP
5151 character(s) starting at the current cursor position with
5153 and advance the cursor.
5155 [\f2count\fP]\f3x\fP
5156 Delete current character.
5158 [\f2count\fP]\f3X\fP
5159 Delete preceding character.
5161 [\f2count\fP]\f3.\fP
5162 Repeat the previous text modification command.
5164 [\f2count\fP]\f3\(ap\fP
5165 Invert the case of the
5167 character(s) starting at the current cursor position and advance the cursor.
5169 [\f2count\fP]\f3_\fP
5172 word of the previous command to be appended and
5174 The last word is used
5182 to be appended to the current word and file name generation attempted.
5183 If no match is found,
5185 Otherwise, the word is replaced
5186 by the matching pattern and input mode is entered.
5189 Command or file name completion as described above.
5191 .SS "\ \ \ \ \ Other Edit Commands"
5193 Miscellaneous commands.
5195 [\f2count\fP]\f3y\fP\f2motion\fP
5197 \f3y\fP[\f2count\fP]\f2motion\fP
5198 Yank current character through character that
5200 would move the cursor to and puts them into the delete buffer.
5201 The text and cursor are unchanged.
5204 Yanks the entire line.
5207 Yanks from current position to end of line.
5212 Undo the last text modifying command.
5215 Undo all the text modifying commands performed on the line.
5217 [\f2count\fP]\f3v\fP
5219 .BI "hist \-e ${\s-1VISUAL\s+1:\-${\s-1EDITOR\s+1:\-vi}}" " count"
5220 in the input buffer.
5223 is omitted, then the current line is used.
5226 Line feed and print current line.
5227 Has effect only in control mode.
5230 (New\ line) Execute the current line, regardless of mode.
5233 (Return) Execute the current line, regardless of mode.
5236 If the first character of the command is a
5238 then this command deletes this
5242 that follows a newline.
5244 sends the line after
5247 in front of each line in the command.
5248 Useful for causing the current line to be
5249 inserted in the history as a comment and
5250 uncommenting previously commented commands
5251 in the history file.
5253 [\f2count\fP]\f3=\fP
5254 If \f2count\fP is not specified,
5255 it generates the list of matching commands or
5256 file names as described above.
5257 Otherwise, the word under the the cursor is replaced by the
5258 \f2count\fP item from the most recently generated command or file list.
5259 If the cursor is not on a word, it is inserted instead.
5262 Your alias list is searched for an
5265 and if an alias of this name is defined, its
5266 value will be inserted on the input queue for processing.
5269 Display version of the shell.
5272 .SS Built-in Commands.
5273 The following simple-commands are executed in the shell process.
5274 Input/Output redirection is permitted.
5275 Unless otherwise indicated, the output is written on file descriptor 1
5276 and the exit status, when there is no syntax error, is zero.
5285 all built-in commands accept
5287 to indicate end of options.
5288 They also interpret the option
5290 as a request to display the man page onto
5293 as a help request which prints a
5297 Commands that are preceded by one or two \(dg symbols
5298 are special built-in commands and
5299 are treated specially in the following ways:
5303 Variable assignment lists preceding the command
5304 remain in effect when the command completes.
5307 I/O redirections are processed after variable assignments.
5312 that contains them to abort.
5315 They are not valid function names.
5319 following a command preceded by \(dg\(dg
5320 that are in the format of a variable assignment
5321 are expanded with the same rules as a variable assignment.
5323 tilde substitution is performed after the
5325 sign and field splitting and file name generation are not
5332 \(dg \f3:\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
5333 The command only expands parameters.
5337 \(dg \f3\|. \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
5340 is a function defined with the
5343 reserved word syntax,
5344 the function is executed in the current environment
5345 (as if it had been defined with the
5350 refers to a file, the
5351 file is read in its entirety and the commands are
5352 executed in the current shell environment.
5357 is used to find the directory containing the file.
5361 they become the positional parameters while processing
5364 command and the original positional parameters are restored upon completion.
5365 Otherwise the positional parameters are unchanged.
5366 The exit status is the exit status of the last command executed.
5368 \(dg\(dg \f3alias\fP \*(OK \f3\-ptx\fP \*(CK \*(OK \f2name\fP\*(OK \f3=\fP\f2value\^\fP \*(CK \*(CK .\|.\|.
5370 with no arguments prints the list of aliases
5379 to be inserted before each one.
5380 When one or more arguments are given,
5391 causes the next word to be checked for
5395 option is used to set and list tracked aliases.
5396 The value of a tracked alias is the full pathname
5397 corresponding to the given
5399 The value becomes undefined when the value of
5402 is reset but the alias remains tracked.
5408 in the argument list
5412 and value of the alias is printed.
5415 option has no effect.
5416 The exit status is non-zero if a
5418 is given, but no value, and no alias has been defined for the
5421 \f3bg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
5422 This command is only on systems that support job control.
5425 into the background.
5426 The current job is put in the background
5432 for a description of the format of
5435 \(dg \f3break\fP \*(OK \f2n\^\fP \*(CK
5436 Exit from the enclosing
5445 is specified, then break
5449 \f3builtin\fP \*(OK \f3\-ds\fP \*(CK \*(OK \f3\-f\fP \f2file\^\fP \*(CK \*(OK \f2name\^\fP .\|.\|. \*(CK
5455 option is specified,
5456 the built-ins are printed on standard output.
5459 option prints only the special built-ins.
5462 represents the pathname whose basename is the name of the built-in.
5463 The entry point function name is determined by prepending
5465 to the built-in name.
5466 The ISO C/C++ prototype is
5467 \f3b_\fP\f2mycommand\fP\f3(int\fP \f2argc\fP, \f3char *\fP\f2argv\fP\f3[]\fP, \f3void *\fP\f2context\fP\f3)\fP
5468 for the builtin command
5474 elements and context is an optional pointer to a
5476 structure as described in
5479 Special built-ins cannot be bound to a pathname or deleted.
5482 option deletes each of the given built-ins.
5483 On systems that support dynamic loading, the
5485 option names a shared library containing the code for built-ins.
5486 The shared library prefix and/or suffix, which depend on the system,
5488 Once a library is loaded, its symbols become available
5489 for subsequent invocations of
5491 Multiple libraries can be specified with separate invocations
5495 Libraries are searched in the reverse order in which they are specified.
5496 When a library is loaded, it looks for a function in the library
5499 and invokes this function with an argument of
5503 \f3cd\fP \*(OK \f3\-LP\fP \*(CK \*(OK \f2arg\^\fP \*(CK
5505 \f3cd\fP \*(OK \f3\-LP\fP \*(CK \f2old\^\fP \f2new\^\fP
5507 This command can be in either of two forms.
5508 In the first form it
5509 changes the current directory to
5515 the directory is changed to the previous
5526 is set to the current directory.
5530 defines the search path for
5531 the directory containing
5533 Alternative directory names are separated by
5538 (specifying the current directory).
5539 Note that the current directory is specified by a null path name,
5540 which can appear immediately after the equal sign
5541 or between the colon delimiters anywhere else in the path list.
5544 begins with a \f3/\fP then the search path
5546 Otherwise, each directory in the path is
5552 substitutes the string
5556 in the current directory name,
5559 and tries to change to this new directory.
5561 By default, symbolic link names are treated literally when
5562 finding the directory name.
5563 This is equivalent to the
5569 symbolic links to be resolved when determining the directory.
5570 The last instance of
5575 determines which method is used.
5579 command may not be executed by
5581 .if \nZ=1 .B rksh\^.
5582 .if \nZ=1 .B rksh93\^.
5584 \f3command\fP \*(OK \f3\-pvxV\fP \*(CK \f2name\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
5593 with the arguments given by
5598 a default path to be searched
5599 rather than the one defined by the value of
5602 Functions will not be searched for when finding
5606 refers to a special built-in,
5607 none of the special properties associated with the leading
5608 daggers will be honored.
5609 (For example, the predefined alias
5610 .B "redirect=\(fmcommand exec\(fm"
5611 prevents a script from terminating when an invalid
5612 redirection is given.)
5616 if command execution would result in a failure because
5617 there are too many arguments, errno
5620 the shell will invoke command
5622 multiple times with a subset of the arguments on each invocation.
5623 Arguments that occur prior to the first word that
5624 expands to multiple arguments and after the last word
5625 that expands to multiple arguments will be passed on each invocation.
5626 The exit status will be the maximum invocation exit status.
5631 is equivalent to the built-in
5633 command described below.
5641 \(dg \f3continue\fP \*(OK \f2n\^\fP \*(CK
5642 Resume the next iteration of the enclosing
5651 is specified, then resume at the
5655 \f3disown\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
5656 Causes the shell not to send a HUP signal to
5659 or all active jobs if
5662 when a login shell terminates.
5664 \f3echo\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
5667 does not begin with a \-, and
5668 none of the arguments contain a \e,
5671 prints each of its arguments separated by a space
5672 and terminated by a new-line.
5673 Otherwise, the behavior of
5680 described below should be used.
5683 for usage and description.
5685 \(dg\(dg \f3enum\fP \*(OK \f3\-i\fP \*(CK \f2type\^\fP\*(OK=(\f2value\^\fP .\|.\|.) \*(CK
5686 Creates a declaration command named \f2type\^\fP that is an
5687 integer type that allows one of the specified \f2value\fPs as
5688 enumeration names. If \f3=(\fP\f2value\^\ .\|.\|.\|\fP\f3)\fP is
5689 omitted, then \f2type\^\fP must be an indexed array variable with at
5690 least two elements and the values are taken from this array variable.
5693 is specified the values are case insensitive.
5695 \(dg \f3eval\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
5696 The arguments are read as input
5698 and the resulting command(s) executed.
5700 \(dg \f3exec\fP \*(OK \f3\-c\fP \*(CK \*(OK \f3\-a\fP \f2name\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
5704 the command specified by
5705 the arguments is executed in place of this shell
5706 without creating a new process.
5709 option causes the environment to be cleared before applying
5710 variable assignments associated with the
5718 rather than the first
5722 for the new process.
5723 Input/output arguments may appear and
5724 affect the current process.
5728 the effect of this command is to
5729 modify file descriptors
5730 as prescribed by the input/output redirection list.
5732 any file descriptor numbers greater than 2 that are
5733 opened with this mechanism are closed when invoking
5736 \(dg \f3exit\fP \*(OK \f2n\^\fP \*(CK
5737 Causes the shell to exit
5738 with the exit status specified by
5740 The value will be the least significant 8 bits of the specified status.
5743 is omitted, then the exit status is that of the last command executed.
5744 An end-of-file will also cause the shell to exit
5752 \(dg\(dg \f3export\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2name\^\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
5756 the names and values of each variable with
5757 the export attribute are printed with the values
5758 quoted in a manner that allows them to be re-input.
5764 to be inserted before each one.
5765 Otherwise, the given
5767 are marked for automatic
5770 of subsequently-executed commands.
5773 Does nothing, and exits 1. Used with
5777 \f3fg\fP \*(OK \f2job\^\fP.\|.\|. \*(CK
5778 This command is only on systems that support job control.
5781 specified is brought to the foreground and waited for in
5782 the specified order.
5783 Otherwise, the current job is
5784 brought into the foreground.
5787 for a description of the format of
5790 \f3getconf\fP \*(OK \f2name\^\fP \*(OK \f2pathname\^\fP \*(CK \*(CK
5791 Prints the current value of the configuration parameter given by
5793 The configuration parameters are defined by the IEEE POSIX 1003.1
5794 and IEEE POSIX 1003.2 standards.
5801 argument is required for parameters whose value depends on
5802 the location in the file system.
5803 If no arguments are given,
5805 prints the names and values of the current configuration
5809 is used for each of the parameters that requires
5812 \f3getopts\fP \*(OK \f3\ \-a\fP \f2name\^\fP \*(CK \f2optstring vname\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
5819 the positional parameters are used.
5820 An option argument begins with a
5824 An option not beginning with
5831 Options beginning with
5833 are only recognized when
5838 contains the letters that
5841 If a letter is followed by a
5843 that option is expected to have an argument.
5844 The options can be separated from the argument by blanks.
5849 to generate a usage message on standard error.
5852 argument can be used to specify the name to use for the
5853 usage message, which defaults to
5858 places the next option letter it finds inside variable
5860 each time it is invoked.
5861 The option letter will be prepended with a
5867 The index of the next
5872 The option argument,
5884 to store the letter of an invalid
5892 for an unknown option and to
5894 when a required option argument is missing.
5897 prints an error message.
5898 The exit status is non-zero when there are no more options.
5900 There is no way to specify any of the options
5910 can only be specified as the first option.
5913 \f3hist\fP \*(OK \f3\-e\fP \f2ename\^\fP \ \*(CK \*(OK \f3\-nlr\^\fP \*(CK \*(OK \f2first\^\fP \*(OK \f2last\^\fP \*(CK \*(CK
5915 \f3hist \-s \fP \*(OK \f2old\fP\f3\=\fP\f2new\^\fP \*(CK \*(OK \f2command\^\fP \*(CK
5918 a range of commands from
5922 is selected from the last
5925 commands that were typed at the terminal.
5930 may be specified as a number or as a string.
5931 A string is used to locate the most recent command starting with
5933 A negative number is used as an offset to the current command number.
5938 the commands are listed on standard output.
5939 Otherwise, the editor program
5941 is invoked on a file containing these
5945 is not supplied, then the value of the variable
5957 is used as the editor.
5958 When editing is complete, the edited command(s)
5959 is executed if the changes have been saved.
5963 then it will be set to
5968 the default is the previous command
5969 for editing and \-16 for listing.
5972 reverses the order of the commands and
5975 suppresses command numbers when listing.
5981 and defaults to the last command executed.
5982 The resulting command is executed
5983 after the optional substitution
5984 \f2old\^\fP\f3=\fP\f2new\^\fP
5987 \f3jobs\fP \*(OK \f3\-lnp\^\fP \*(CK \*(OK \f2job\^\fP \.\|.\|. \*(CK
5988 Lists information about each given job; or all active jobs if
5993 option lists process ids in addition to the normal information.
5996 option only displays jobs that have stopped or exited since last
6000 option causes only the process group to be listed.
6003 for a description of the format of
6007 \f3kill\fP \*(OK \f3\-s\fP \f2signame\^\fP \*(CK \f2job\^\fP .\|.\|.
6010 \f3kill\fP \*(OK \f3\-n\fP \f2signum\^\fP \*(CK \f2job\^\fP .\|.\|.
6012 \f3kill\fP \f3\-l\fP \*(OK \f2sig\^\fP .\|.\|. \*(CK
6014 Sends either the TERM (terminate) signal or the
6015 specified signal to the specified jobs or processes.
6016 Signals are either given by number with the
6018 option or by name with the
6023 stripped of the prefix ``SIG'' with
6024 the exception that SIGCLD is named CHLD).
6025 For backward compatibility, the
6029 can be omitted and the number or name placed immediately
6032 If the signal being sent is TERM (terminate) or HUP (hangup),
6033 then the job or process will be sent a CONT (continue) signal
6037 can be the process id of a process that is not a member of one of the
6041 for a description of the format of
6048 the signal names are listed.
6051 that is a name, the corresponding signal number is listed.
6054 that is a number, the signal name corresponding to the
6055 least significant 8 bits of
6059 \f3let\fP \f2arg\^\fP .\|.\|.
6063 .I "arithmetic expression"
6066 .I "Arithmetic Evaluation"
6067 above, for a description of arithmetic expression evaluation.
6070 0 if the value of the last expression
6071 is non-zero, and 1 otherwise.
6073 \(dg \f3newgrp\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
6075 .BI "exec /bin/newgrp" " arg\^"
6078 \f3print\fP \*(OK \f3\-CRenprsv\^\fP \*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f3\-f\fP \f2format\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
6079 With no options or with option
6089 option causes the arguments to be printed as
6097 options are ignored.
6105 are specified, the following
6106 escape conventions will be applied:
6111 The alert character (ascii
6115 The backspace character (ascii
6121 to end without processing more arguments and
6122 not adding a new-line.
6125 The formfeed character (ascii
6129 The new-line character (ascii
6133 The carriage return character (ascii
6137 The tab character (ascii
6141 The vertical tab character (ascii
6145 The escape character (ascii
6149 The backslash character \e.
6152 The character defined by the 1, 2, or 3-digit octal
6153 string given by \fIx\fP.
6158 option will print all subsequent arguments and options
6163 causes the above escape conventions to be applied.
6164 This is the default behavior.
6165 It reverses the effect of an earlier
6170 arguments to be written onto the pipe
6171 of the process spawned with
6173 instead of standard output.
6178 as a variable name and writes the value in
6187 as a variable name and writes the value in
6195 arguments to be written onto the history file
6196 instead of standard output.
6199 option can be used to specify a one digit
6200 file descriptor unit number
6203 output will be placed.
6209 is added to the output.
6212 \f3printf\fP \f2format\^\fP \*(OK \f2arg\^\fP .\|.\|. \*(CK
6215 are printed on standard output
6216 in accordance with the ANSI-C
6217 formatting rules associated with the format string
6219 If the number of arguments exceeds the number of
6220 format specifications, the
6222 string is reused to format remaining arguments.
6223 The following extensions can also be used:
6230 format can be used instead of
6232 to cause escape sequences in the corresponding
6234 to be expanded as described in
6240 option causes each of the arguments to be treated
6241 as variable names and the binary value of variable
6245 causes a compound variable to be output on a single line.
6246 This is most useful for compound variables and variables whose attribute
6253 format can be used instead of
6255 to cause characters in
6257 that are special in HTML and XML
6258 to be output as their entity name.
6263 format can be used instead of
6267 to be interpreted as an extended regular
6268 expression and be printed as a shell pattern.
6273 format can be used instead of
6277 to be interpreted as a shell pattern
6278 and to be printed as an extended regular expression.
6283 format can be used instead of
6285 to cause the resulting string to be quoted in a manner than can
6286 be reinput to the shell.
6288 .BI %( date-format )T
6290 .BI %( date-format )T
6291 format can be use to treat an argument as a date/time string
6292 and to format the date/time according to the
6301 format will output a byte whose value is 0.
6304 The precision field of the
6306 format can be followed by a
6308 and the output base.
6311 flag character causes
6318 flag when used with the
6320 specifier without an output base,
6321 causes the output to be displayed in thousands units with one of the suffixes
6323 to indicate the unit.
6326 flag when used with the
6328 specifier causes the output to be displayed in 1024 with one of the suffixes
6329 .B "Ki Mi Gi Ti Pi Ei"
6330 to indicate the unit.
6335 flag has been added to center the output within the specified field width.
6340 \f3pwd\fP \*(OK \f3\-LP\fP \*(CK
6341 Outputs the value of the current working
6345 option is the default; it prints the logical name of the current directory.
6349 all symbolic links are resolved from the name.
6350 The last instance of
6355 determines which method is used.
6357 \f3read\fP \*(OK \f3\-ACprsv\^\fP \*(CK \*(OK \f3\-d\fP \f2delim\^\fP\*(CK \*(OK \f3\-n\fP \f2n\^\fP\*(CK \*(OK \*(OK \f3\-N\fP \f2n\^\fP\*(CK \*(OK \*(OK \f3\-t\fP \f2timeout\^\fP\*(CK \*(OK \f3\-u\fP \f2unit\^\fP\*(CK \*(OK \f2vname\f3?\f2prompt\^\f1 \*(CK \*(OK \f2vname\^\fP .\|.\|. \*(CK
6358 The shell input mechanism.
6359 One line is read and
6360 is broken up into fields using the characters in
6364 The escape character,
6366 is used to remove any special meaning for the next
6367 character and for line continuation.
6371 causes the read to continue to the first character of
6373 rather than new-line.
6376 option causes at most
6378 bytes to read rather a full line
6379 but will return when reading from a slow device
6380 as soon as any characters have been read.
6383 option causes exactly
6385 to be read unless an end-of-file has been encountered or
6386 the read times out because of the
6393 character is not treated specially.
6395 field is assigned to the first
6400 etc., with leftover fields assigned to the last
6404 has the binary attribute and
6408 is specified, the bytes that are read are stored directly
6412 is specified, then the value of the first
6414 will be used as a default value when reading from a terminal device.
6417 option causes the variable
6419 to be unset and each field that is read to be stored in
6420 successive elements of the indexed array
6424 option causes the variable
6426 to be read as a compound variable. Blanks will be ignored when
6427 finding the beginning open parenthesis.
6430 option causes the input line
6431 to be taken from the input pipe
6432 of a process spawned by the shell
6438 the input will be saved as a command in the history file.
6441 can be used to specify a one digit file
6445 The file descriptor can be opened with the
6447 special built-in command.
6448 The default value of unit
6453 is used to specify a timeout in
6454 seconds when reading from a terminal or pipe.
6460 is used as the default
6462 An end-of-file with the
6464 option causes cleanup for this process
6465 so that another can be spawned.
6466 If the first argument contains a
6468 the remainder of this word is used as a
6471 when the shell is interactive.
6472 The exit status is 0 unless an end-of-file is encountered
6477 \(dg\(dg \f3readonly\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2vname\fP\*(OK\f3=\fP\f2value\^\fP\*(CK \*(CK .\|.\|.
6481 the names and values of each variable with
6482 the readonly attribute is printed with the values
6483 quoted in a manner that allows them to be re-inputted.
6489 to be inserted before each one.
6490 Otherwise, the given
6494 names cannot be changed
6495 by subsequent assignment.
6496 When defining a type, if the value of a readonly sub-variable is not defined
6497 the value is required when creating each instance.
6499 \(dg \f3return\fP \*(OK \f2n\^\fP \*(CK
6505 to the invoking script
6506 with the exit status specified by
6508 The value will be the least significant 8 bits of the specified status.
6511 is omitted, then the return status is that of the last command executed.
6514 is invoked while not in a
6519 then it behaves the same as
6522 \(dg \f3set\fP \*(OK \f3\(+-BCGabefhkmnoprstuvx\fP \*(CK \*(OK \f3\(+-o\fP \*(OK \f2option\^\fP \*(CK \*(CK .\|.\|. \*(OK \f3\(+-A\fP \f2vname\^\fP \*(CK \*(OK \f2arg\^\fP .\|.\|. \*(CK
6523 The options for this command have meaning as follows:
6531 and assign values sequentially from the
6536 is used, the variable
6541 Enable brace pattern field generation.
6542 This is the default behavior.
6545 Enable brace group expansion. On by default.
6548 Prevents redirection
6550 from truncating existing files.
6551 Files that are created are opened with the O_EXCL mode.
6554 to truncate a file when turned on.
6559 by itself to match files and zero or more directories and sub-directories
6560 when used for file name generation.
6563 only directories and sub-directories are matched.
6566 All subsequent variables that are defined are automatically exported.
6569 Prints job completion messages as soon as a background job changes
6570 state rather than waiting for the next prompt.
6573 Unless contained in a
6577 command, or the command following an
6582 command or in the pipeline following
6584 if a command has a non-zero exit status,
6590 This mode is disabled while reading profiles.
6593 Disables file name generation.
6597 becomes a tracked alias when first encountered.
6600 (Obsolete). All variable assignment arguments are placed in the environment for a command,
6601 not just those that precede the command name.
6604 Background jobs will run in a separate process group
6605 and a line will print upon completion.
6606 The exit status of background jobs is reported in a completion message.
6607 On systems with job control,
6608 this option is turned on automatically for
6612 Read commands and check them for syntax errors, but do not execute them.
6613 Ignored for interactive shells.
6616 The following argument can be one of the following option names:
6628 All background jobs are run at a lower priority.
6629 This is the default mode.
6638 style in-line editor for command entry.
6647 style in-line editor for command entry.
6650 The shell will not exit on end-of-file.
6660 All directory names resulting from file name generation have a trailing
6669 The built-in editors will use multiple lines on the screen for lines
6670 that are longer than the width of the screen. This may not work
6686 Do not save function definitions in the history file.
6697 A pipeline will not complete until all components
6698 of the pipeline have completed, and the return value
6699 will be the value of the last non-zero command
6700 to fail or zero if no command has failed.
6703 When enabled, simple commands or pipelines preceded by a semicolon
6705 will be displayed as if the
6707 option were enabled but will not be executed.
6708 Otherwise, the leading
6725 Puts you in insert mode of a
6727 style in-line editor
6728 until you hit the escape character
6730 This puts you in control mode.
6731 A return sends the line.
6734 Each character is processed as it is typed
6743 If no option name is supplied, then the current option settings are printed.
6747 Disables processing of the
6748 .B \s-1$HOME\s+1/.profile
6749 file and uses the file
6750 .B /etc/suid_profile
6755 This mode is on whenever the effective uid (gid)
6756 is not equal to the real uid (gid).
6757 Turning this off causes the effective uid and gid to be
6758 set to the real uid and gid.
6761 Enables the restricted shell. This option cannot be unset
6765 Sort the positional parameters lexicographically.
6768 (Obsolete). Exit after reading and executing one command.
6771 Treat unset parameters as an error when substituting.
6774 Print shell input lines as they are read.
6777 Print commands and their arguments as they are executed.
6780 Do not change any of the options; useful in setting
6782 to a value beginning with
6784 If no arguments follow this option then the positional parameters are unset.
6787 As an obsolete feature,
6796 options are turned off and the next
6798 is treated as the first argument.
6803 causes these options to be turned off.
6804 These options can also be used upon invocation of the shell.
6805 The current set of options may be found in
6810 the remaining arguments are positional
6811 parameters and are assigned, in order, to
6815 If no arguments are given, then the names and values
6816 of all variables are printed on the standard output.
6819 \(dg \f3shift\fP \*(OK \f2n\^\fP \*(CK
6821 The positional parameters from
6822 \f3$\fP\f2n\fP\f3+1\fP
6832 can be any arithmetic expression that evaluates to a non-negative
6833 number less than or equal to
6836 \f3sleep\fP \f2seconds\^\fP
6837 Suspends execution for the number of decimal seconds or fractions of a
6841 \(dg \f3trap\fP \*(OK \f3\-p\fP \*(CK \*(OK \f2action\^\fP \*(CK \*(OK \f2sig\^\fP \*(CK .\|.\|.
6844 option causes the trap
6845 action associated with each trap as specified by the arguments
6846 to be printed with appropriate quoting.
6849 will be processed as if it were an argument to
6856 can be given as a number or as the name of the signal.
6857 Trap commands are executed in order of signal number.
6858 Any attempt to set a trap on a signal that
6859 was ignored on entry to the current shell
6863 is omitted and the first
6869 then the trap(s) for each
6872 to their original values.
6876 string then this signal is ignored by the shell and by the commands
6885 will be executed whenever a command has a non-zero exit status.
6893 will be executed before each command.
6896 will contain the contents of the current command line
6900 If the exit status of the trap is
6902 the command will not be executed.
6903 If the exit status of the trap is
6905 and inside a function or a dot script,
6906 the function or dot script will return.
6916 statement is executed inside the body of a function defined with the
6923 after the function completes.
6933 set outside any function
6937 on exit from the shell.
6945 will be executed whenever a key is read
6955 with no arguments prints a list
6956 of commands associated with each signal number.
6962 without an argument in a trap action will
6963 preserve the exit status of the command that invoked the trap.
6966 Does nothing, and exits 0. Used with
6971 Does nothing, and exits 0. Used with
6975 \(dg\(dg \f3typeset\fP \*(OK \f3\(+-ACHSflbnprtux\^\fP \*(CK \*(OK \f3\(+-EFLRXZi\*(OK\f2n\^\fP\*(CK \*(CK \*(OK \f3\-T \f2tname\fP=(\f2assign_list\fP) \*(CK \*(OK \f3\-h \f2str\fP \*(CK \*(OK \f3\-a\fP \*(OK\f2type\fP\*(CK \*(CK \*(OK \f2vname\^\fP\*(OK\f3=\fP\f2value\^\fP \*(CK \^ \*(CK .\|.\|.
6976 Sets attributes and values for shell variables and functions.
6977 When invoked inside a function defined with the
6981 a new instance of the variable
6984 and the variable's value and type are restored
6985 when the function completes.
6986 The following list of attributes may be specified:
6993 to be an associative array.
6994 Subscripts are strings rather than arithmetic
7000 to be a compound variable.
7002 names a compound variable it is copied into
7004 Otherwise, it unsets each
7010 to be an indexed array.
7013 is specified, it must be the name of an enumeration
7014 type created with the
7016 command and it allows enumeration constants to be used
7022 to be a double precision floating point number.
7025 is non-zero, it defines the number of significant figures
7026 that are used when expanding
7028 Otherwise, ten significant figures will be used.
7033 to be a double precision floating point number.
7036 is non-zero, it defines the number of places after the
7037 decimal point that are used when expanding
7039 Otherwise ten places after the decimal point will be used.
7042 This option provides UNIX to host-name file mapping on non-UNIX
7046 Left justify and remove leading blanks from
7050 is non-zero, it defines the width
7052 otherwise it is determined by the width of the value of
7054 When the variable is assigned to, it is
7055 filled on the right with blanks or truncated, if necessary, to
7059 option is turned off.
7062 Right justify and fill with leading blanks.
7065 is non-zero, it defines the width
7067 otherwise it is determined by the width of the value of
7069 The field is left filled with blanks or
7070 truncated from the end if the
7071 variable is reassigned.
7074 option is turned off.
7077 When used within the
7079 of a type definition, it causes the specified sub-variable
7080 to be shared by all instances of the type.
7081 When used inside a function defined with the
7083 reserved word, the specified variables will have
7084 .I "function static\^"
7086 Otherwise, the variable is unset prior to processing the assignment list.
7089 Creates a type named by \fItname\^\fP using the compound
7097 to be a double precision floating point number
7098 and expands using the
7103 is non-zero, it defines the number of hex digits after
7104 the radix point that is used when expanding
7109 Right justify and fill with leading zeros if
7110 the first non-blank character is a digit and the
7112 option has not been set.
7113 Remove leading zeros if the
7118 is non-zero, it defines the width
7120 otherwise it is determined by the width of the value of
7124 The names refer to function names rather than
7126 No assignments can be made and the only other
7135 turns on execution tracing for this function.
7139 causes this function to be marked undefined.
7143 variable will be searched to find the function definition
7144 when the function is referenced.
7145 If no options other than
7147 is specified, then the function definition will be displayed
7148 on standard output. If
7150 is specified, then a line containing the function name followed
7151 by a shell comment containing the line number and path name of the
7152 file where this function was defined, if any, is displayed.
7155 The variable can hold any number of bytes of data.
7156 The data can be text or binary.
7157 The value is represented by the base64 encoding of the data.
7160 is also specified, the size in bytes of the
7161 data in the buffer will be determined by the size associated with the
7163 If the base64 string assigned results in more data, it will be
7164 truncated. Otherwise, it will be filled with bytes
7165 whose value is zero.
7170 can be used to output the actual data in this buffer instead
7171 of the base64 encoding of the data.
7174 Used within type definitions to add information when generating
7175 information about the sub-variable on the man page.
7176 It is ignored when used outside of a type definition.
7179 the information is associated with the corresponding discipline
7185 to be represented internally as integer.
7186 The right hand side of an assignment is evaluated as an
7187 arithmetic expression when assigning to an integer.
7190 is non-zero, it defines the output arithmetic base,
7191 otherwise the output base will be ten.
7194 All upper-case characters are
7195 converted to lower-case.
7196 The upper-case option,
7203 to be a reference to the variable whose name is
7204 defined by the value of variable
7206 This is usually used to reference a variable inside
7207 a function whose name has been passed as an argument.
7210 The name, attributes and values for the given
7212 are written on standard output in a form that can be
7213 used as shell input.
7216 is specified, then the values are not displayed.
7223 names cannot be changed
7224 by subsequent assignment.
7228 Tags are user definable and have no special
7229 meaning to the shell.
7232 All lower-case characters are converted
7234 The lower-case option,
7241 are marked for automatic
7244 of subsequently-executed commands.
7245 Variables whose names contain a \fB\s+2.\s-2\fP
7251 attribute cannot be specified along with
7262 causes these options to be turned off.
7265 arguments are given,
7278 values from being printed.)
7283 followed by the option letters
7284 to be printed before each name
7285 rather than the names of the options.
7286 If any option other than
7289 only those variables
7290 which have all of the given
7291 options are printed.
7298 that have attributes
7302 \f3ulimit\fP \*(OK \f3\-HSacdfmnpstv\fP \*(CK \*(OK \f2limit\^\fP \*(CK
7303 Set or display a resource limit.
7304 The available resource limits are listed below.
7305 Many systems do not support one or more of these limits.
7306 The limit for a specified resource is set when
7311 can be a number in the unit specified below with each resource,
7318 options specify whether the hard limit or the
7319 soft limit for the given resource is set.
7320 A hard limit cannot be increased once it is set. A soft
7321 limit can be increased up to the value of the hard limit.
7326 option is specified, the limit applies to both.
7327 The current resource limit is printed when
7330 In this case, the soft limit is printed unless
7333 When more than one resource is specified, then the limit
7334 name and unit is printed before the value.
7339 Lists all of the current resource limits.
7342 The number of 512-byte blocks on the size of core dumps.
7345 The number of K-bytes on the size of the data area.
7348 The number of 512-byte blocks on files that can be written by the
7349 current process or by child processes (files of any size may be read).
7352 The number of K-bytes on the size of physical memory.
7355 The number of file descriptors plus 1.
7358 The number of 512-byte blocks for pipe buffering.
7361 The number of K-bytes on the size of the stack area.
7364 The number of CPU seconds to be used by each process.
7367 The number of K-bytes for virtual memory.
7370 If no option is given,
7375 \f3umask\fP \*(OK \f3\-S\fP \*(CK \*(OK \f2mask\^\fP \*(CK
7376 The user file-creation mask is set to
7381 can either be an octal number or
7382 a symbolic value as described in
7384 If a symbolic value is given,
7386 umask value is the complement of the result of
7389 to the complement of the previous umask value.
7392 is omitted, the current value of the mask is printed.
7395 option causes the mode to be printed as a symbolic
7396 value. Otherwise, the
7397 mask is printed in octal.
7399 \(dg \f3unalias\fP \*(OK \f3\-a\fP \*(CK \f2name\^\fP .\|.\|.
7401 given by the list of
7403 are removed from the alias list.
7406 option causes all the
7407 aliases to be unset.
7409 \(dg\f3unset\fP \*(OK \f3\-fnv\fP \*(CK \f2vname\^\fP .\|.\|.
7410 The variables given by the list of
7414 except for sub-variables within a type,
7415 their values and attributes are erased.
7416 For sub-variables of a type, the values are reset to the
7417 default value from the type definition.
7418 Readonly variables cannot be unset.
7422 is set, then the names refer to
7427 option is set, then the names refer to
7438 is a name reference, then
7440 will be unset rather than the variable
7442 The default is equivalent to
7462 removes their special meaning even if they are
7463 subsequently assigned to.
7465 \f3wait\fP \*(OK \f2job\^\fP .\|.\|. \*(CK
7466 Wait for the specified
7469 report its termination status.
7472 is not given, then all currently active child processes are waited for.
7473 The exit status from this command is that of
7474 the last process waited for if
7476 is specified; otherwise it is zero.
7479 for a description of the format of
7482 \f3whence\fP \*(OK \f3\-afpv\fP \*(CK \f2name\^\fP .\|.\|.
7486 would be interpreted if used as a command name.
7491 produces a more verbose report.
7494 option skips the search for functions.
7498 does a path search for
7500 even if name is an alias, a function, or a reserved word.
7503 option turns off the
7512 all interpretations of the given name to be reported.
7514 If the shell is invoked by
7516 and the first character of argument zero
7520 then the shell is assumed to be a
7523 commands are read from
7525 and then from either
7527 in the current directory or
7528 .BR \s-1$HOME\s+1/.profile ,
7529 if either file exists.
7530 Next, for interactive shells, commands are read from
7532 performing parameter expansion, command substitution,
7533 and arithmetic substitution on
7534 the value of the environment variable
7540 option is not present and
7542 and a file by the name of
7544 exists, then it reads and executes this script.
7545 Otherwise, if the first
7549 a path search is performed on the first
7551 to determine the name of the script to execute.
7554 must have execute permission and any
7558 settings will be ignored.
7559 If the script is not found on the path,
7561 is processed as if it named a built-in command or function.
7562 Commands are then read as described below;
7563 the following options are interpreted by the shell
7569 Do not execute the script, but output the set of double quoted strings
7572 These strings are needed for localization of the script to different locales.
7575 Reads the file named by the
7578 \s-1$HOME\s+1/\f3.\fPkshrc
7579 if not defined after the profiles.
7584 option is present, then
7585 commands are read from the first
7587 Any remaining arguments become
7588 positional parameters starting at
7594 option is present or if no
7596 then commands are read from the standard input.
7598 except for the output of the
7599 .I Special Commands\^
7607 option is present or
7608 if the shell input and output are attached to a terminal (as told by
7612 In this case \s-1TERM\s+1 is ignored (so that \f3kill 0\fP
7613 does not kill an interactive shell) and \s-1INTR\s+1 is caught and ignored
7617 In all cases, \s-1QUIT\s+1 is ignored by the shell.
7622 option is present, the shell is a restricted shell.
7625 A list of all double quoted strings that are preceded by a
7627 will be printed on standard output and the shell will exit.
7628 This set of strings will be subject to language translation
7629 when the locale is not C or POSIX.
7630 No commands will be executed.
7638 is present, the shell is a profile shell (see
7641 .BI \-R " filename\^"
7646 to generate a cross reference database
7647 that can be used by a separate utility
7648 to find definitions and references for variables and commands.
7650 The remaining options and arguments are described under the
7655 as the first argument is ignored.
7656 .if \nZ=0 \{.SS Rsh Only.
7658 .if \nZ=1 \{.SS Rksh Only.
7660 .if \nZ=2 \{.SS Rksh93 Only.
7662 is used to set up login names and execution environments whose
7663 capabilities are more controlled than those of the standard shell.
7667 .if \nZ=2 .B rksh93\^
7668 are identical to those of
7669 .if \nZ=0 .BR sh\^ ,
7670 .if \nZ=1 .BR ksh\^ ,
7671 .if \nZ=2 .BR ksh93\^ ,
7672 except that the following are disallowed:
7676 Unsetting the restricted option.
7678 changing directory (see
7681 setting or unsetting the value or attributes of
7693 command names containing
7703 adding or deleting built-in commands.
7707 to invoke a command.
7711 The restrictions above are enforced
7712 after \f3.profile\fP and the
7715 files are interpreted.
7717 When a command to be executed is found to be a shell procedure,
7718 .if \nZ=0 \{.B rsh\^
7721 .if \nZ=1 \{.B rksh\^
7724 .if \nZ=2 \{.B rksh93\^
7728 Thus, it is possible to provide to the end-user shell procedures
7729 that have access to the full power of
7731 while imposing a limited menu of commands;
7732 this scheme assumes that the end-user does not have write and
7733 execute permissions in the same directory.
7735 The net effect of these rules is that the writer of the
7737 has complete control over user actions,
7738 by performing guaranteed setup actions
7739 and leaving the user in an appropriate directory
7742 the login directory).
7744 The system administrator often sets up a directory
7748 that can be safely invoked by
7750 .if \nZ=1 .BR rksh .
7751 .if \nZ=2 .BR rksh93 .
7753 Errors detected by the shell, such as syntax errors,
7755 to return a non-zero exit status.
7756 If the shell is being used non-interactively,
7757 then execution of the shell file is abandoned
7758 unless the error occurs inside a subshell in which case
7759 the subshell is abandoned.
7760 Otherwise, the shell returns the exit status of
7761 the last command executed (see also the
7764 Run time errors detected by the shell are reported by
7765 printing the command or function name and the error condition.
7766 If the line number that the error occurred on is greater than one,
7767 then the line number is also printed in square brackets
7769 after the command or function name.
7773 The system wide initialization file, executed for login shells.
7777 The system wide startup file, executed for interactive shells.
7780 .B \s-1$HOME\s+1/\f3.\fPprofile
7781 The personal initialization file, executed for login shells after /etc/profile.
7783 \s-1$HOME\s+1/\f3.\fP.kshrc
7784 Default personal initialization file, executed for interactive shells when
7789 .B /etc/suid_profile
7790 Alternative initialization file, executed when instead of personal initialization file when the real and effective user or group id do not match.
7830 Morris I. Bolsky and David G. Korn,
7831 .IR "The New KornShell Command and Programming Language" ,
7832 Prentice Hall, 1995.
7834 .I "POSIX \- Part 2: Shell and Utilities,"
7835 IEEE Std 1003.2-1992, ISO/IEC 9945-2, IEEE, 1993.
7839 is executed, and then a command with the same name is
7840 installed in a directory in the search path before the directory where the
7841 original command was found, the shell will continue to
7843 the original command.
7848 command to correct this situation.
7850 Some very old shell scripts contain a
7852 as a synonym for the pipe character
7857 built-in command within a compound command will cause the whole
7858 command to disappear from the history file.
7860 The built-in command \f3\|.\fP \f2file\^\fP
7861 reads the whole file before any commands are executed.
7866 commands in the file
7867 will not apply to any commands defined in the file.
7869 Traps are not processed while a job is waiting for a foreground process.
7872 won't be executed until the foreground job terminates.
7874 It is a good idea to leave a space after the comma operator in
7875 arithmetic expressions to prevent the comma from being interpreted
7876 as the decimal point character in certain locales.