1KSH(1)                      General Commands Manual                     KSH(1)
2
3
4

NAME

6       ksh,  rksh  -  KornShell, a standard/restricted command and programming
7       language
8

SYNOPSIS

10       ksh [ ±abcefhiklmnprstuvxBCDEGH ] [ ±o option ] ... [ - ] [ arg ... ]
11       rksh [ ±abcefhiklmnpstuvxBCDEGH ] [ ±o option ] ... [ - ] [ arg ... ]
12

DESCRIPTION

14       Ksh is a command and programming language that executes  commands  read
15       from a terminal or a file.  Rksh is a restricted version of the command
16       interpreter ksh; it is used to set up login names and  execution  envi‐
17       ronments whose capabilities are more controlled than those of the stan‐
18       dard shell.  See Invocation below for the meaning of arguments  to  the
19       shell.
20
21   Definitions.
22       A metacharacter is one of the following characters:
23
24              ;   &   (   )   |   <   >   new-line   space   tab
25
26       A  blank  is a tab or a space.  An identifier is a sequence of letters,
27       digits, or underscores starting with a letter or  underscore.   Identi‐
28       fiers  are used as components of variable names.  A vname is a sequence
29       of one or more identifiers separated by a . and optionally preceded  by
30       a  ..  Vnames are used as function and variable names.  A word is a se‐
31       quence of characters from the character set defined by the current  lo‐
32       cale, excluding non-quoted metacharacters.
33
34       A  command  is a sequence of characters in the syntax of the shell lan‐
35       guage.  The shell reads each command and carries out the desired action
36       either  directly or by invoking separate utilities.  A built-in command
37       is a command that is carried out by the shell itself without creating a
38       separate  process.   Some  commands are built-in purely for convenience
39       and are not documented here.  Built-ins that cause side effects in  the
40       shell environment and built-ins that are found before performing a path
41       search (see Execution below) are documented here.  For historical  rea‐
42       sons,  some  of these built-ins behave differently than other built-ins
43       and are called special built-ins.
44
45   Commands.
46       A simple-command is a list of variable assignments  (see  Variable  As‐
47       signments  below)  or  a sequence of blank separated words which may be
48       preceded by a list of variable  assignments  (see  Environment  below).
49       The  first  word specifies the name of the command to be executed.  Ex‐
50       cept as specified below, the remaining words are passed as arguments to
51       the  invoked  command.   The  command name is passed as argument 0 (see
52       exec(2)).  The value of a simple-command is its exit status;  0-255  if
53       it  terminates  normally;  256+signum  if it terminates abnormally (the
54       name of the signal corresponding to the exit status can be obtained via
55       the -l option of the kill built-in utility).
56
57       A  pipeline  is a sequence of one or more commands separated by |.  The
58       standard output of each command but the last is connected by a  pipe(2)
59       to the standard input of the next command.  Each command, except possi‐
60       bly the last, is run as a separate process; the  shell  waits  for  the
61       last  command  to terminate.  The exit status of a pipeline is the exit
62       status of the last command unless the pipefail option is enabled.  Each
63       pipeline  can be preceded by the reserved word !  which causes the exit
64       status of the pipeline to become 0 if the exit status of the last  com‐
65       mand is non-zero, and 1 if the exit status of the last command is 0.
66
67       A  list  is  a sequence of one or more pipelines separated by ;, &, |&,
68       &&, or ||, and optionally terminated by ;, &, or  |&.   Of  these  five
69       symbols,  ;,  &, and |& have equal precedence, which is lower than that
70       of && and ||.  The symbols && and || also  have  equal  precedence.   A
71       semicolon (;) causes sequential execution of the preceding pipeline; an
72       ampersand (&) causes asynchronous execution of the  preceding  pipeline
73       (i.e.,  the shell does not wait for that pipeline to finish).  The sym‐
74       bol |& causes asynchronous execution of the preceding pipeline  with  a
75       two-way  pipe  established  to the parent shell; the standard input and
76       output of the spawned pipeline can be written to and read from  by  the
77       parent shell by applying the redirection operators <& and >& with arg p
78       to commands and by using -p option of the built-in  commands  read  and
79       print described later.  The symbol && (||) causes the list following it
80       to be executed only if the preceding pipeline returns a zero (non-zero)
81       value.   One  or more new-lines may appear in a list instead of a semi‐
82       colon, to delimit a command.  The first item  of the first pipeline  of
83       a  list  that is a simple command not beginning with a redirection, and
84       not occurring within a while, until, or if list, can be preceded  by  a
85       semicolon.   This  semicolon is ignored unless the showme option is en‐
86       abled as described with the set built-in below.
87
88       A command is either a simple-command or one of the  following.   Unless
89       otherwise  stated,  the value returned by a command is that of the last
90       simple-command executed in the command.
91
92       for vname [ in word ... ] ;do list ;done
93              Each time a for command is executed, vname is set  to  the  next
94              word  taken  from the in word list.  If in word ...  is omitted,
95              then the for command executes the do list once  for  each  posi‐
96              tional  parameter that is set starting from 1 (see Parameter Ex‐
97              pansion below).  Execution ends when there are no more words  in
98              the list.
99
100       for (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done
101              The  arithmetic  expression expr1 is evaluated first (see Arith‐
102              metic evaluation below).  The arithmetic expression expr2 is re‐
103              peatedly evaluated until it evaluates to zero and when non-zero,
104              list is executed and the arithmetic expression expr3  evaluated.
105              If any expression is omitted, then it behaves as if it evaluated
106              to 1.
107
108       select vname [ in word ... ] ;do list ;done
109              A select command prints on standard error  (file  descriptor  2)
110              the set of words, each preceded by a number.  If in word ...  is
111              omitted, then the positional parameters starting from 1 are used
112              instead  (see  Parameter  Expansion  below).   The PS3 prompt is
113              printed and a line is read from the  standard  input.   If  this
114              line consists of the number of one of the listed words, then the
115              value of the variable vname is set to the word corresponding  to
116              this  number.   If  this  line  is  empty, the selection list is
117              printed again.  Otherwise the value of the variable vname is set
118              to  null.   The contents of the line read from standard input is
119              saved in the variable REPLY.  The list is executed for each  se‐
120              lection until a break or end-of-file is encountered.  If the RE‐
121              PLY variable is set to null by the execution of list,  then  the
122              selection  list  is printed before displaying the PS3 prompt for
123              the next selection.
124
125       case word in [ [(]pattern [ | pattern ] ... ) list ;; ] ... esac
126              A case command executes the list associated with the first  pat‐
127              tern that matches word.  The form of the patterns is the same as
128              that used for file name generation (see File Name Generation be‐
129              low).   The  ;;  operator causes execution of case to terminate.
130              If ;& is used in place of ;; the next subsequent list,  if  any,
131              is executed.
132
133       if list ;then list [ ;elif list ;then list ] ... [ ;else list ] ;fi
134              The list following if is executed and, if it returns a zero exit
135              status, the list following the first then is  executed.   Other‐
136              wise,  the  list following elif is executed and, if its value is
137              zero, the list following the next  then  is  executed.   Failing
138              each successive elif list, the else list is executed.  If the if
139              list has non-zero exit status and there is no  else  list,  then
140              the if command returns a zero exit status.
141
142       while list ;do list ;done
143       until list ;do list ;done
144              A  while  command repeatedly executes the while list and, if the
145              exit status of the last command in the list  is  zero,  executes
146              the  do  list; otherwise the loop terminates.  If no commands in
147              the do list are executed, then the while command returns a  zero
148              exit  status;  until may be used in place of while to negate the
149              loop termination test.
150
151       ((expression))
152              The expression is evaluated using the rules for arithmetic eval‐
153              uation  described below.  If the value of the arithmetic expres‐
154              sion is non-zero, the exit status is 0, otherwise the exit  sta‐
155              tus is 1.
156
157       (list)
158              Execute list in a separate environment.  Note, that if two adja‐
159              cent open parentheses are needed for nesting, a  space  must  be
160              inserted  to  avoid  evaluation  as an arithmetic command as de‐
161              scribed above.
162
163       { list;}
164              list is simply executed.  Note that unlike the metacharacters  (
165              and  ),  { and } are reserved words and must occur at the begin‐
166              ning of a line or after a ; in order to be recognized.
167
168       [[ expression ]]
169              Evaluates expression and returns a zero exit status when expres‐
170              sion is true.  See Conditional Expressions below, for a descrip‐
171              tion of expression.
172
173       function varname { list ;}
174       varname () { list ;}
175              Define a function which is referenced by  varname.   A  function
176              whose  varname contains a .  is called a discipline function and
177              the portion of the varname preceding the last .  must  refer  to
178              an  existing  variable.  The body of the function is the list of
179              commands between { and }.  A function defined with the  function
180              varname syntax can also be used as an argument to the .  special
181              built-in command to get the equivalent behavior as if  the  var‐
182              name() syntax were used to define it.  (See Functions below.)
183
184       namespace identifier { list ;}
185              Defines  or uses the name space identifier and runs the commands
186              in list in this name space.  (See Name Spaces below.)
187
188       & [ name [ arg... ]  ]
189              Causes subsequent list commands terminated by & to be placed  in
190              the  background job pool name.  If name is omitted a default un‐
191              named pool is used.  Commands in a named background pool may  be
192              executed remotely.
193
194       time [ pipeline ]
195              If  pipeline is omitted the user and system time for the current
196              shell and completed child processes is printed on  standard  er‐
197              ror.   Otherwise,  pipeline  is executed and the elapsed time as
198              well as the user and system time are printed on standard  error.
199              The TIMEFORMAT variable may be set to a format string that spec‐
200              ifies how the timing information should be displayed.  See Shell
201              Variables below for a description of the TIMEFORMAT variable.
202
203       The  following reserved words are recognized as reserved only when they
204       are the first word of a command and are not quoted:
205
206       if then else elif fi case esac for while until do done { } function se‐
207       lect time [[ ]] !
208
209   Variable Assignments.
210       One  or  more variable assignments can start a simple command or can be
211       arguments to the typeset, enum, export, or  readonly  special  built-in
212       commands  as  well  as  to other declaration commands created as types.
213       The syntax for an assignment is of the form:
214
215       varname=word
216       varname[word]=word
217              No space is permitted between varname and the = or between = and
218              word.
219
220       varname=(assign_list)
221              No  space  is permitted between varname and the =.  The variable
222              varname is unset before the assignment.  An assign_list  can  be
223              one of the following:
224                      word ...
225                             Indexed array assignment.
226                      [word]=word ...
227                             Associative  array  assignment.   If  preceded by
228                             typeset -a this will create an indexed array  in‐
229                             stead.
230                      assignment ...
231                             Compound  variable  assignment.   This  creates a
232                             compound variable varname with  sub-variables  of
233                             the  form  varname.name,  where  name is the name
234                             portion of assignment.  The value of varname will
235                             contain  all the assignment elements.  Additional
236                             assignments made to sub-variables of varname will
237                             also  be  displayed  as part of the value of var‐
238                             name.  If no assignments are  specified,  varname
239                             will  be a compound variable allowing subsequence
240                             child elements to be defined.
241                      typeset [options] assignment ...
242                             Nested variable assignment.  Multiple assignments
243                             can  be specified by separating each of them with
244                             a ;.  The previous value is unset before the  as‐
245                             signment.   Other  declaration  commands  such as
246                             readonly, enum, and  other  declaration  commands
247                             can be used in place of typeset.
248                      . filename
249                             Include  the  assignment  commands  contained  in
250                             filename.
251
252       In addition, a += can be used in place of the = to signify adding to or
253       appending  to  the previous value.  When += is applied to an arithmetic
254       type, word is evaluated as an arithmetic expression and  added  to  the
255       current value.  When applied to a string variable, the value defined by
256       word is appended to the value.  For compound assignments, the  previous
257       value  is not unset and the new values are appended to the current ones
258       provided that the types are compatible.
259
260       The right hand side of a variable assignment undergoes all  the  expan‐
261       sion listed below except word splitting, brace expansion, and file name
262       generation.  When the left hand side is an  assignment  is  a  compound
263       variable  and  the  right  hand is the name of a compound variable, the
264       compound variable on the right will be copied or appended to  the  com‐
265       pound variable on the left.
266
267   Comments.
268       A  word beginning with # causes that word and all the following charac‐
269       ters up to a new-line to be ignored.
270
271   Aliasing.
272       The first word of each command is replaced by the text of an  alias  if
273       an alias for this word has been defined.  An alias name consists of any
274       number of characters excluding metacharacters, quoting characters, file
275       expansion  characters,  parameter  expansion  and  command substitution
276       characters, the characters / and =.  The replacement string can contain
277       any  valid shell script including the metacharacters listed above.  The
278       first word of each command in the replaced text, other  than  any  that
279       are  in  the process of being replaced, will be tested for aliases.  If
280       the last character of the alias value is a blank then the word  follow‐
281       ing the alias will also be checked for alias substitution.  Aliases can
282       be used to redefine built-in commands but cannot be  used  to  redefine
283       the  reserved  words  listed  above.  Aliases can be created and listed
284       with the alias command and can be removed with the unalias command.
285
286       Aliasing is performed when scripts are read, not while  they  are  exe‐
287       cuted.   Therefore,  for  an alias to take effect, the alias definition
288       command has to be executed before  the  command  which  references  the
289       alias is read.
290
291       The  following  aliases  are automatically preset when the shell is in‐
292       voked as an interactive shell, unless invoked in POSIX compliance  mode
293       (see Invocation below).  Preset aliases can be unset or redefined.
294                           history=′hist -l′
295                           r=′hist -s′
296
297   Tilde Expansion.
298       After  alias  substitution is performed, each word is checked to see if
299       it begins with an unquoted .  For tilde expansion, word also refers to
300       the  word  portion  of parameter expansion (see Parameter Expansion be‐
301       low).  If a word is preceded by a tilde, then it is checked up to  a  /
302       to  see  if it matches a user name in the password database (see getpw‐
303       name(3)).  If a match is found, the and the matched  login  name  are
304       replaced  by  the  login directory of the matched user.  If no match is
305       found, the original text is left unchanged.  A by itself, or in front
306       of  a  /,  is  replaced by $HOME, unless the HOME variable is unset, in
307       which case the current user's home directory as configured in the oper‐
308       ating  system is used.  A followed by a + or - is replaced by $PWD or
309       $OLDPWD respectively.
310
311       In addition, when expanding a variable assignment (see Variable Assign‐
312       ments  above),  tilde  expansion is attempted when the value of the as‐
313       signment begins with a , and when a appears after a  :.   A  :  also
314       terminates a user name following a .
315
316       The  tilde  expansion mechanism may be extended or modified by defining
317       one of the discipline functions  .sh.tilde.set  or  .sh.tilde.get  (see
318       Functions and Discipline Functions below).  If either exists, then upon
319       encountering a tilde word to expand, that function is called  with  the
320       tilde  word  assigned  to either .sh.value (for the .sh.tilde.set func‐
321       tion) or .sh.tilde (for the .sh.tilde.get function).  Performing  tilde
322       expansion  within  a discipline function will not recursively call that
323       function, but default tilde expansion remains active, so literal tildes
324       should  still  be  quoted where required.  Either function may assign a
325       replacement string to .sh.value.  If this value is non-empty  and  does
326       not  start  with  a , it replaces the default tilde expansion when the
327       function terminates.  Otherwise, the tilde expansion is left unchanged.
328
329   Command Substitution.
330       The standard output from a command list enclosed  in  parentheses  pre‐
331       ceded  by  a dollar sign ( $(list) ), or in a brace group preceded by a
332       dollar sign ( ${ list;} ), or in a pair of grave accents  (``)  may  be
333       used  as part or all of a word; trailing new-lines are removed.  In the
334       second case, the { and } are treated as a reserved words so that { must
335       be  followed  by a blank and } must appear at the beginning of the line
336       or follow a ;.  In the third (obsolete) form, the  string  between  the
337       quotes  is  processed for special quoting characters before the command
338       is executed (see Quoting below).  The command substitution $(cat  file)
339       can  be  replaced  by  the equivalent but faster $(<file).  The command
340       substitution $(n<#) will expand to the current byte offset for file de‐
341       scriptor  n.   Except for the second form, the command list is run in a
342       subshell so that no side effects are possible.  For  the  second  form,
343       the final } will be recognized as a reserved word after any token.
344
345   Arithmetic Substitution.
346       An  arithmetic  expression enclosed in double parentheses preceded by a
347       dollar sign ( $(()) ) is replaced by the value of  the  arithmetic  ex‐
348       pression within the double parentheses.
349
350   Process Substitution.
351       Each  command  argument of the form <(list) or >(list) will run process
352       list asynchronously connected to some file in /dev/fd if this directory
353       exists,  or  else  a fifo a temporary directory.  The name of this file
354       will become the argument to the command.  If the form  with  >  is  se‐
355       lected  then writing on this file will provide input for list.  If < is
356       used, then the file passed as an argument will contain  the  output  of
357       the list process.  For example,
358
359              paste  <(cut  -f1  file1)  <(cut  -f3  file2)  | tee >(process1)
360              >(process2)
361
362       cuts fields 1 and 3 from the files file1 and file2 respectively, pastes
363       the  results  together,  and  sends  it  to  the processes process1 and
364       process2, as well as putting it onto the standard  output.   Note  that
365       the  file,  which  is  passed  as an argument to the command, is a UNIX
366       pipe(2) so programs that expect to lseek(2) on the file will not work.
367
368       Process substitution of the form <(list) can also be used  with  the  <
369       redirection operator which causes the output of list to be standard in‐
370       put or the input for whatever file descriptor is specified.
371
372   Parameter Expansion.
373       A parameter is a variable, one or more digits, or any of the characters
374       *,  @, #, ?, -, $, and !.  A variable is denoted by a vname.  To create
375       a variable whose vname contains a ., a variable whose vname consists of
376       everything  before  the  last  .  must already exist.  A variable has a
377       value and zero or more attributes.  Variables can  be  assigned  values
378       and  attributes by using the typeset special built-in command.  The at‐
379       tributes supported by the shell are described later  with  the  typeset
380       special  built-in command.  Exported variables pass their attributes to
381       the environment so that a newly invoked ksh that is a child or  exec'ed
382       process of the current shell will automatically import them, unless the
383       posix shell option is on.
384
385       The shell supports both indexed and associative arrays.  An element  of
386       an array variable is referenced by a subscript.  A subscript for an in‐
387       dexed array is denoted by  an  arithmetic  expression  (see  Arithmetic
388       evaluation  below) between a [ and a ].  To assign values to an indexed
389       array, use vname=(value ...) or set -A vname  value ... .  The value of
390       all  non-negative  subscripts  must  be  in  the  range  of  0  through
391       4,194,303.  A negative subscript is treated as an offset from the maxi‐
392       mum  current  index  +1 so that -1 refers to the last element.  Indexed
393       arrays can be declared with the -a option to typeset.   Indexed  arrays
394       need  not  be  declared.  Any reference to a variable with a valid sub‐
395       script is legal and an array will be created if necessary.
396
397       An associative array is created with the -A option to typeset.  A  sub‐
398       script for an associative array is denoted by a string enclosed between
399       [ and ].
400
401       Referencing any array without a subscript is equivalent to  referencing
402       the array with subscript 0.
403
404       The value of a variable may be assigned by writing:
405
406              vname=value [ vname=value ] ...
407
408       or
409              vname[subscript]=value [ vname[subscript]=value ] ...
410       Note that no space is allowed before or after the =.
411       Attributes  assigned  by  the typeset special built-in command apply to
412       all elements of the array.  An array element can be a simple  variable,
413       a compound variable or an array variable.  An element of an indexed ar‐
414       ray can be either an indexed array or an associative array.  An element
415       of  an associative array can also be either.  To refer to an array ele‐
416       ment that is part of an array element,  concatenate  the  subscript  in
417       brackets.   For  example, to refer to the foobar element of an associa‐
418       tive array that is defined as the third element of the  indexed  array,
419       use ${vname[3][foobar]}
420       A  nameref  is  a  variable that is a reference to another variable.  A
421       nameref is created with the -n attribute of typeset.  The value of  the
422       variable  at  the time of the typeset command becomes the variable that
423       will be referenced whenever the nameref variable is used.  The name  of
424       a  nameref  cannot  contain a ..  When a variable or function name con‐
425       tains a ., and the portion of the name up to the first  .  matches  the
426       name  of  a  nameref, the variable referred to is obtained by replacing
427       the nameref portion with the name of the  variable  referenced  by  the
428       nameref.   If a nameref is used as the index of a for loop, a name ref‐
429       erence is established for each item in the list.  A nameref provides  a
430       convenient way to refer to the variable inside a function whose name is
431       passed as an argument to a function.  For example, if  the  name  of  a
432       variable is passed as the first argument to a function, the command
433              typeset -n var=$1
434       inside the function causes references and assignments to var to be ref‐
435       erences and assignments to the variable whose name has been  passed  to
436       the function.
437       If  any of the floating point attributes, -E, -F, or -X, or the integer
438       attribute, -i, is set for vname, then the value is  subject  to  arith‐
439       metic evaluation as described below.
440       Positional  parameters, parameters denoted by a number, may be assigned
441       values with the set special built-in command.  Parameter $0 is set from
442       argument zero when the shell is invoked.
443       The character $ is used to introduce substitutable parameters.
444       ${parameter}
445              The  shell reads all the characters from ${ to the matching } as
446              part of the same word even if it contains braces or  metacharac‐
447              ters.   The value, if any, of the parameter is substituted.  The
448              braces are required when parameter  is  followed  by  a  letter,
449              digit,  or  underscore  that is not to be interpreted as part of
450              its name, when the variable name contains a ..  The  braces  are
451              also  required  when a variable is subscripted unless it is part
452              of an Arithmetic Expression or a Conditional Expression.  If pa‐
453              rameter is one or more digits then it is a positional parameter.
454              A positional parameter of more than one digit must  be  enclosed
455              in  braces.  If parameter is * or @, then all the positional pa‐
456              rameters, starting with $1,  are  substituted  (separated  by  a
457              field  separator  character).   If an array vname with last sub‐
458              script * @, or for indexed arrays of the form sub1 ..  sub2.  is
459              used,  then  the value for each of the elements between sub1 and
460              sub2 inclusive (or all elements for *  and  @)  is  substituted,
461              separated by the first character of the value of IFS.
462       ${#parameter}
463              If  parameter  is * or @, the number of positional parameters is
464              substituted.  Otherwise, the length of the value of the  parame‐
465              ter is substituted.
466       ${#vname[*]}
467       ${#vname[@]}
468              The number of elements in the array vname is substituted.
469
470       ${@vname}
471              Expands  to  the  type  name  (See Type Variables  below) or at‐
472              tributes of the variable referred to by vname.
473       ${!vname}
474              Expands to the name of the variable referred to by vname.   This
475              will be vname except when vname is a name reference.
476       ${!vname[subscript]}
477              Expands  to  name of the subscript unless subscript is *, @.  or
478              of the form sub1 ..  sub2.  When subscript is *, the list of ar‐
479              ray  subscripts  for vname is generated.  For a variable that is
480              not an array, the value is 0 if the variable is set.   Otherwise
481              it  is  null.   When  subscript is @, same as above, except that
482              when used in double quotes, each array subscript yields a  sepa‐
483              rate  argument.   When subscript is of the form sub1 ..  sub2 it
484              expands to the list of subscripts between sub1 and  sub2  inclu‐
485              sive using the same quoting rules as @.
486       ${!prefix@}
487       ${!prefix*}
488              These  both expand to the names of the variables whose names be‐
489              gin with prefix.  The expansions otherwise work like $@ and  $*,
490              respectively (see under Quoting below).
491       ${parameter:-word}
492              If  parameter  is set and is non-null then substitute its value;
493              otherwise substitute word.
494       ${parameter:=word}
495              If parameter is not set or is null then  set  it  to  word;  the
496              value  of the parameter is then substituted.  Positional parame‐
497              ters may not be assigned to in this way.
498       ${parameter:?word}
499              If parameter is set and is non-null then substitute  its  value;
500              otherwise,  print  word and exit from the shell (if not interac‐
501              tive).  If word is omitted then a standard message is printed.
502       ${parameter:+word}
503              If parameter is set and is non-null then substitute word; other‐
504              wise substitute nothing.
505       In the above, word is not evaluated unless it is to be used as the sub‐
506       stituted string, so that, in the following  example,  pwd  is  executed
507       only if d is not set or is null:
508              print ${d:-$(pwd)}
509       If  the  colon  (  :  ) is omitted from the above expressions, then the
510       shell only checks whether parameter is set or not.
511       ${parameter:offset:length}
512       ${parameter:offset}
513              Expands to the portion of the value of parameter starting at the
514              character (counting from 0) determined by expanding offset as an
515              arithmetic expression and consisting of the number of characters
516              determined  by  the arithmetic expression defined by length.  In
517              the second form, the remainder of the value is used.  If A nega‐
518              tive  offset  counts  backwards from the end of parameter.  Note
519              that one or more blanks is required in front of a minus sign  to
520              prevent  the shell from interpreting the operator as :-.  If pa‐
521              rameter is * or @, or is an array name indexed by * or  @,  then
522              offset  and  length  refer to the array index and number of ele‐
523              ments respectively.  A negative offset is taken relative to  one
524              greater  than the highest subscript for indexed arrays.  The or‐
525              der for associative arrays is unspecified.
526       ${parameter#pattern}
527       ${parameter##pattern}
528              If the shell pattern matches the beginning of the value  of  pa‐
529              rameter,  then  the  value of this expansion is the value of the
530              parameter with the matched portion deleted; otherwise the  value
531              of  this parameter is substituted.  In the first form the small‐
532              est matching pattern is deleted  and  in  the  second  form  the
533              largest matching pattern is deleted.  When parameter is @, *, or
534              an array variable with subscript @ or *, the substring operation
535              is applied to each element in turn.
536
537       ${parameter%pattern}
538       ${parameter%%pattern}
539              If  the shell pattern matches the end of the value of parameter,
540              then the value of this expansion is the value of  the  parameter
541              with the matched part deleted; otherwise substitute the value of
542              parameter.  In the first form the smallest matching  pattern  is
543              deleted  and  in the second form the largest matching pattern is
544              deleted.  When parameter is @, *, or an array variable with sub‐
545              script  @  or *, the substring operation is applied to each ele‐
546              ment in turn.
547
548       ${parameter/pattern/string}
549       ${parameter//pattern/string}
550       ${parameter/#pattern/string}
551       ${parameter/%pattern/string}
552              Expands parameter and replaces the longest match of pattern with
553              the  given  string.  Each occurrence of \n in string is replaced
554              by the portion of parameter that matches the  n-th  sub-pattern.
555              In  the  first form, only the first occurrence of pattern is re‐
556              placed.  In the second form, each match for pattern is  replaced
557              by the given string.  The third form restricts the pattern match
558              to the beginning of the string while the fourth  form  restricts
559              the  pattern  match  to  the  end of the string.  When string is
560              null, the pattern will be deleted and the / in front  of  string
561              may  be  omitted.   When parameter is @, *, or an array variable
562              with subscript @ or *, the substitution operation is applied  to
563              each  element in turn.  In this case, the string portion of word
564              will be re-evaluated for each element.
565
566       The following parameters are automatically set by the shell:
567              #      The number of positional parameters in decimal.
568              -      Options supplied to the shell on invocation or by the set
569                     command.
570              ?      The decimal value returned by the last executed command.
571              $      The process id of this shell.
572              _      Initially,  the value of _ is an absolute pathname of the
573                     shell or script being executed as passed in the  environ‐
574                     ment.   Subsequently  it is assigned the last argument of
575                     the previous command.  This parameter is not set for com‐
576                     mands  which  are  asynchronous.   This parameter is also
577                     used to hold the name of  the  matching  MAIL  file  when
578                     checking for mail.  While defining a compound variable or
579                     a type, _ is initialized as a reference to  the  compound
580                     variable or type.  When a discipline function is invoked,
581                     _ is initialized as a reference to the  variable  associ‐
582                     ated  with  the call to this function.  Finally when _ is
583                     used as the name of the first variable of a type  defini‐
584                     tion,  the new type is derived from the type of the first
585                     variable. (See Type Variables  below.)
586              !      The process id or the pool name and  job  number  of  the
587                     last  background  command  invoked or the most recent job
588                     put in the  background  with  the  bg  built-in  command.
589                     Background  jobs  started  in a named pool will be in the
590                     form pool.number where pool is the pool name  and  number
591                     is the job number within that pool.
592              .sh.command
593                     When  processing a DEBUG trap, this variable contains the
594                     current command line that is about to run.  Each argument
595                     is  shell-quoted  as  necessary so that the value is safe
596                     for being evaluated by the shell.
597              .sh.edchar
598                     This variable contains the value of the keyboard  charac‐
599                     ter  (or sequence of characters if the first character is
600                     an ESC, ascii 033) that has been entered when  processing
601                     a  KEYBD  trap (see Key Bindings below).  If the value is
602                     changed as part of the trap action, then  the  new  value
603                     replaces the key (or key sequence) that caused the trap.
604              .sh.edcol
605                     The  character  position of the cursor at the time of the
606                     most recent KEYBD trap.
607              .sh.edmode
608                     The value is set to ESC  when  processing  a  KEYBD  trap
609                     while  in  vi insert mode.  (See Vi Editing Mode  below.)
610                     Otherwise, .sh.edmode is null  when  processing  a  KEYBD
611                     trap.
612              .sh.edtext
613                     The  characters  in  the  input buffer at the time of the
614                     most recent KEYBD trap.  The value is null when not  pro‐
615                     cessing a KEYBD trap.
616              .sh.file
617                     The  pathname  of the file that contains the current com‐
618                     mand.
619              .sh.fun
620                     The name of the current function that is being executed.
621              .sh.level
622                     Set to the current function depth.  This can  be  changed
623                     inside a DEBUG trap and will set the context to the spec‐
624                     ified level.
625              .sh.lineno
626                     Set during a DEBUG trap to the line number for the caller
627                     of each function.
628              .sh.match
629                     An  indexed  array which stores the most recent match and
630                     sub-pattern matches  after  conditional  pattern  matches
631                     that match and after variables expansions using the oper‐
632                     ators #, %, or /.  The 0-th element stores  the  complete
633                     match  and  the  i-th.  element stores the i-th submatch.
634                     The .sh.match variable becomes unset  when  the  variable
635                     that has expanded is assigned a new value.
636              .sh.math
637                     Used  for  defining  arithmetic functions (see Arithmetic
638                     evaluation below) and stores the  list  of  user  defined
639                     arithmetic functions.
640              .sh.name
641                     Set to the name of the variable at the time that a disci‐
642                     pline function is invoked.
643              .sh.subscript
644                     Set to the name subscript of the  variable  at  the  time
645                     that a discipline function is invoked.
646              .sh.subshell
647                     The current depth for subshells and command substitution.
648              .sh.pid
649                     Set to the process ID of the current shell.  This is dis‐
650                     tinct from $$ as in forked subshells this is set  to  the
651                     process  ID of the subshell instead of the parent shell's
652                     process ID.  In virtual  subshells  .sh.pid  retains  its
653                     previous value.
654              .sh.value
655                     Set to the value of the variable at the time that the set
656                     or append discipline function is invoked.   When  a  user
657                     defined  arithmetic  function  is  invoked,  the value of
658                     .sh.value is saved and .sh.value is set  to  long  double
659                     precision floating point.  .sh.value is restored when the
660                     function returns.
661              .sh.version
662                     Set to a value that identifies the version of this shell.
663              KSH_VERSION
664                     A name reference to .sh.version.
665              LINENO The current line number within the script or function be‐
666                     ing executed.
667              OLDPWD The previous working directory set by the cd command.
668              OPTARG The  value  of  the last option argument processed by the
669                     getopts built-in command.
670              OPTIND The index of the last option argument  processed  by  the
671                     getopts built-in command.
672              PPID   The process id of the parent of the shell.
673              PWD    The present working directory set by the cd command.
674              RANDOM Each  time this variable is referenced, a random integer,
675                     uniformly distributed between 0 and 32767, is  generated.
676                     The  sequence of random numbers can be initialized by as‐
677                     signing a numeric value to RANDOM.
678              REPLY  This variable is set by the select statement and  by  the
679                     read built-in command when no arguments are supplied.
680              SECONDS
681                     Each time this variable is referenced, the number of sec‐
682                     onds since shell invocation is returned.  If  this  vari‐
683                     able  is  assigned  a value, then the value returned upon
684                     reference will be the value that was  assigned  plus  the
685                     number of seconds since the assignment.
686              SHLVL  An  integer  variable  the  is  incremented each time the
687                     shell is invoked and is exported.  If SHLVL is not in the
688                     environment when the shell is invoked, it is set to 1.
689
690       The following variables are used by the shell:
691              CDPATH The search path for the cd command.
692              COLUMNS
693                     If  this variable is set, the value is used to define the
694                     width of the edit window for the shell edit modes and for
695                     printing select lists.
696              EDITOR If  the  VISUAL  variable  is  not set, the value of this
697                     variable will be checked for the  patterns  as  described
698                     with  VISUAL  below  and the corresponding editing option
699                     (see Special Command set below) will be turned on.
700              ENV    If this variable is set, then parameter  expansion,  com‐
701                     mand  substitution,  and arithmetic substitution are per‐
702                     formed on the value  to  generate  the  pathname  of  the
703                     script  that  will  be executed when the shell is invoked
704                     interactively (see Invocation below).  This file is typi‐
705                     cally  used  for alias and function definitions.  The de‐
706                     fault value is $HOME/.kshrc.  On systems that  support  a
707                     system  wide   /etc/ksh.kshrc initialization file, if the
708                     filename generated by the expansion of  ENV  begins  with
709                     /./  or ././ the system wide initialization file will not
710                     be executed.
711              FCEDIT Obsolete name for the default editor name  for  the  hist
712                     command.  FCEDIT is not used when HISTEDIT is set.
713              FIGNORE
714                     A  pattern that defines the set of filenames that will be
715                     ignored when performing filename matching.
716              FPATH  The search path for function definitions.   The  directo‐
717                     ries  in  this path are searched for a file with the same
718                     name as the function or command when a function with  the
719                     -u  attribute  is  referenced  and  when a command is not
720                     found.  If an executable file with the name of that  com‐
721                     mand  is  found, then it is read and executed in the cur‐
722                     rent environment.  Unlike  PATH,  the  current  directory
723                     must be represented explicitly by .  rather than by adja‐
724                     cent : characters or a beginning or ending :.
725              HISTCMD
726                     Number of the current command in the history file.
727              HISTEDIT
728                     Name for the default editor name for the hist command.
729              HISTFILE
730                     If this variable is set when the shell is  invoked,  then
731                     the  value  is the pathname of the file that will be used
732                     to store the command history (see  Command  Re-entry  be‐
733                     low).
734              HISTSIZE
735                     If  this  variable is set when the shell is invoked, then
736                     the number of previously entered commands that are acces‐
737                     sible by this shell will be greater than or equal to this
738                     number.  The default is 512.
739              HOME   The default argument (home directory) for the cd command.
740              IFS    Internal field separators, normally space, tab, and  new-
741                     line  that  are  used  to separate the results of command
742                     substitution  or  parameter  expansion  and  to  separate
743                     fields with the built-in command read.  The first charac‐
744                     ter of the IFS variable is used to separate arguments for
745                     the  "$*"  substitution (see Quoting below).  Each single
746                     occurrence of an IFS character in the string to be split,
747                     that is not in the isspace character class, and any adja‐
748                     cent characters in IFS that are in the isspace  character
749                     class,  delimit  a  field.  One or more characters in IFS
750                     that belong to the isspace  character  class,  delimit  a
751                     field.   In  addition,  if the same isspace character ap‐
752                     pears consecutively inside IFS, this character is treated
753                     as  if  it  were not in the isspace class, so that if IFS
754                     consists of two tab characters,  then  two  adjacent  tab
755                     characters delimit a null field.
756              JOBMAX This  variable  defines  the maximum number running back‐
757                     ground jobs that can run at a time.  When this  limit  is
758                     reached, the shell will wait for a job to complete before
759                     staring a new job.
760              LANG   This variable determines the locale category for any cat‐
761                     egory  not specifically selected with a variable starting
762                     with LC_ or LANG.
763              LC_ALL This variable overrides the value of  the  LANG  variable
764                     and any other LC_ variable.
765              LC_COLLATE
766                     This  variable determines the locale category for charac‐
767                     ter collation information.
768              LC_CTYPE
769                     This variable determines the locale category for  charac‐
770                     ter  handling  functions.   It  determines  the character
771                     classes for pattern matching (see  File  Name  Generation
772                     below).
773              LC_NUMERIC
774                     This variable determines the locale category for the dec‐
775                     imal point character.
776              LINES  If this variable is set, the value is used  to  determine
777                     the  column  length  for  printing  select lists.  Select
778                     lists will print vertically  until  about  two-thirds  of
779                     LINES lines are filled.
780              MAIL   If  this  variable  is set to the name of a mail file and
781                     the MAILPATH variable is not set, then the shell  informs
782                     the user of arrival of mail in the specified file.
783              MAILCHECK
784                     This  variable specifies how often (in seconds) the shell
785                     will check for changes in the modification time of any of
786                     the  files  specified  by the MAILPATH or MAIL variables.
787                     The default value is 600  seconds.   When  the  time  has
788                     elapsed  the  shell  will  check  before issuing the next
789                     prompt.
790              MAILPATH
791                     A colon ( : ) separated list  of  file  names.   If  this
792                     variable  is  set, then the shell informs the user of any
793                     modifications to the specified files that  have  occurred
794                     within the last MAILCHECK seconds.  Each file name can be
795                     followed by a ?  and a message that will be printed.  The
796                     message will undergo parameter expansion, command substi‐
797                     tution, and arithmetic substitution with the variable  $_
798                     defined  as  the  name of the file that has changed.  The
799                     default message is you have mail in $_.
800              PATH   The search path for commands (see Execution below).   The
801                     user  may not change PATH if executing under rksh (except
802                     in .profile).
803              PS1    Every time a new command line is started on  an  interac‐
804                     tive shell, the value of this variable is expanded to re‐
805                     solve backslash escaping,  parameter  expansion,  command
806                     substitution,  and  arithmetic  substitution.  The result
807                     defines the primary prompt string for that command  line.
808                     The  default  is ``$ ''.  The character !  in the primary
809                     prompt string is replaced by the command number (see Com‐
810                     mand  Re-entry  below).   Two successive occurrences of !
811                     will produce a  single  !   when  the  prompt  string  is
812                     printed.  Note that any terminal escape sequences used in
813                     the PS1 prompt thus need every instance of !  in them  to
814                     be changed to !!.
815              PS2    Secondary prompt string, by default ``> ''.
816              PS3    Selection prompt string used within a select loop, by de‐
817                     fault ``#? ''.
818              PS4    The value of this  variable  is  expanded  for  parameter
819                     evaluation,  command substitution, and arithmetic substi‐
820                     tution and precedes each line of an execution trace.   By
821                     default,  PS4  is ``+ ''.  In addition when PS4 is unset,
822                     the execution trace prompt is also ``+ ''.
823              SHELL  The pathname of the shell is kept in the environment.  At
824                     invocation,  if  the  basename  of  this variable is rsh,
825                     rksh, or krsh, then the shell becomes restricted.
826              TIMEFORMAT
827                     The value of this parameter is used as  a  format  string
828                     specifying  how the timing information for pipelines pre‐
829                     fixed with the time reserved word  should  be  displayed.
830                     The  % character introduces a format sequence that is ex‐
831                     panded to a time value or other information.  The  format
832                     sequences and their meanings are as follows.
833                     %%        A literal %.
834                     %[p][l]R  The elapsed time in seconds.
835                     %[p][l]U  The number of CPU seconds spent in user mode.
836                     %[p][l]S  The number of CPU seconds spent in system mode.
837                     %P        The CPU percentage, computed as (U + S) / R.
838
839                     The brackets denote optional portions.  The optional p is
840                     a digit specifying the precision,  the  number  of  frac‐
841                     tional digits after a decimal point.  A value of 0 causes
842                     no decimal point or fraction to be output.  At most three
843                     places  after  the decimal point can be displayed; values
844                     of p greater than 3 are treated as 3.  If p is not speci‐
845                     fied, the value 3 is used.
846
847                     The optional l specifies a longer format, including hours
848                     if greater than zero, minutes, and seconds  of  the  form
849                     HHhMMmSS.FFs.   The  value of p determines whether or not
850                     the fraction is included.
851
852                     All other characters are  output  without  change  and  a
853                     trailing  newline is added.  If unset, the default value,
854                     $'\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS', is used.  If  the
855                     value is null, no timing information is displayed.
856
857              TMOUT  Terminal  read  timeout.  If  set to a value greater than
858                     zero, the read built-in command and the  select  compound
859                     command time out after TMOUT seconds when input is from a
860                     terminal.  An interactive shell will issue a warning  and
861                     allow  for an extra 60 second timeout grace period before
862                     terminating if a line is  not  entered  within  the  pre‐
863                     scribed  number of seconds while reading from a terminal.
864                     (Note that the shell can be compiled with a maximum bound
865                     for this value which cannot be exceeded.)
866
867              VISUAL If  the  value  of  this  variable  matches  the  pattern
868                     *[Vv][Ii]*, then the vi option (see Special  Command  set
869                     below)  is  turned  on.  If the value matches the pattern
870                     *gmacs* , the gmacs option is turned on.   If  the  value
871                     matches the pattern *macs*, then the emacs option will be
872                     turned on.  The value of VISUAL overrides  the  value  of
873                     EDITOR.
874
875       The  shell gives default values to PATH, PS1, PS2, PS3, PS4, MAILCHECK,
876       FCEDIT, TMOUT and IFS, while HOME, SHELL, ENV, and MAIL are not set  at
877       all  by  the shell (although HOME is set by login(1)).  On some systems
878       MAIL and SHELL are also set by login(1).
879
880   Field Splitting.
881       After parameter expansion and command substitution, the results of sub‐
882       stitutions  are scanned for the field separator characters (those found
883       in IFS) and split into distinct fields where such characters are found.
884       Explicit  null  fields  (""  or ′′) are retained.  Implicit null fields
885       (those resulting from parameters that have no values or command substi‐
886       tutions with no output) are removed.
887
888   Brace Expansion.
889       If the braceexpand (-B) option is set then each of the fields resulting
890       from IFS are checked to see if they contain one or more  of  the  brace
891       patterns  {*,*},  {l1..l2} , {n1..n2} , {n1..n2% fmt} , {n1..n2 ..n3} ,
892       or {n1..n2 ..n3%fmt} , where * represents any character, l1,l2 are let‐
893       ters  and  n1,n2,n3 are signed numbers and fmt is a format specified as
894       used by printf.  In each case, fields are  created  by  prepending  the
895       characters  before  the  {  and appending the characters after the } to
896       each of the strings generated by the characters between the  {  and  }.
897       The  resulting  fields  are  checked to see if they have any brace pat‐
898       terns.
899
900       In the first form, a field is created for each string between { and  ,,
901       between  , and ,, and between , and }.  The string represented by * can
902       contain embedded matching { and } without quoting.  Otherwise,  each  {
903       and } with * must be quoted.
904
905       In  the  seconds form, l1 and l2 must both be either upper case or both
906       be lower case characters in the C locale.  In this case a field is cre‐
907       ated for each character from l1 thru l2.
908
909       In  the remaining forms, a field is created for each number starting at
910       n1 and continuing until it reaches n2 incrementing n1 by n3.  The cases
911       where n3 is not specified behave as if n3 where 1 if n1<=n2 and -1 oth‐
912       erwise.  If forms which specify %fmt any format flags, widths and  pre‐
913       cisions  can  be  specified  and  fmt  can end in any of the specifiers
914       cdiouxX.  For  example,  {a,z}{1..5..3%02d}{b..c}x  expands  to  the  8
915       fields, a01bx, a01cx, a04bx, a04cx, z01bx, z01cx, z04bx and z04cx.
916
917   File Name Generation.
918       Following  splitting, each field is scanned for the characters *, ?, (,
919       and [ unless the -f option has been set.  If one  of  these  characters
920       appears, then the word is regarded as a pattern.  Each file name compo‐
921       nent that contains any pattern character is  replaced  with  a  lexico‐
922       graphically  sorted set of names that matches the pattern from that di‐
923       rectory.  If no file name is found that matches the pattern, then  that
924       component  of the filename is left unchanged unless the pattern is pre‐
925       fixed with ∼(N) in which case it is removed as  described  below.   The
926       special  traversal  names  .  and ..  are never matched.  If FIGNORE is
927       set, then each file name component that matches the pattern defined  by
928       the value of FIGNORE is ignored when generating the matching filenames.
929       If FIGNORE is not set, the character .  at the start of each file  name
930       component  will  be  ignored  unless the first character of the pattern
931       corresponding to this component is the character .  itself.  Note, that
932       for  other  uses  of pattern matching the / and .  are not treated spe‐
933       cially.
934
935              *      Matches any string, including the null string.  When used
936                     for  filename expansion, if the globstar option is on, an
937                     isolated pattern of two adjacent *'s will match all files
938                     and zero or more directories and subdirectories.  If fol‐
939                     lowed by a / then  only  directories  and  subdirectories
940                     will match.
941              ?      Matches any single character.
942              [...]  Matches  any  one  of the enclosed characters.  A pair of
943                     characters separated by - matches any character lexically
944                     between the pair, inclusive.  If the first character fol‐
945                     lowing the opening [ is a !  or ^ then any character  not
946                     enclosed  is matched.  A - can be included in the charac‐
947                     ter set by putting it as the first or last character.
948                     Within [ and ], character classes can be  specified  with
949                     the  syntax [:class:] where class is one of the following
950                     classes defined in the ANSI-C standard: (Note  that  word
951                     is equivalent to alnum plus the character _.)
952                     alnum  alpha  blank  cntrl  digit graph lower print punct
953                     space upper word xdigit
954                     Within [ and ], an equivalence  class  can  be  specified
955                     with  the  syntax [=c=] which matches all characters with
956                     the same primary collation weight (as defined by the cur‐
957                     rent  locale) as the character c.  Within [ and ], [.sym‐
958                     bol.]  matches the collating symbol symbol.
959       A pattern-list is a list of one or more patterns  separated  from  each
960       other  with  a & or |.  A & signifies that all patterns must be matched
961       whereas | requires that only one pattern be  matched.   Composite  pat‐
962       terns can be formed with one or more of the following sub-patterns:
963              ?(pattern-list)
964                     Optionally matches any one of the given patterns.
965              *(pattern-list)
966                     Matches zero or more occurrences of the given patterns.
967              +(pattern-list)
968                     Matches one or more occurrences of the given patterns.
969              {n}(pattern-list)
970                     Matches n occurrences of the given patterns.
971              {m,n}(pattern-list)
972                     Matches  from  m  to n occurrences of the given patterns.
973                     If m is omitted, 0 will be used.   If  n  is  omitted  at
974                     least m occurrences will be matched.
975              @(pattern-list)
976                     Matches exactly one of the given patterns.
977              !(pattern-list)
978                     Matches anything except one of the given patterns.
979       By  default, each pattern, or sub-pattern will match the longest string
980       possible consistent with generating the longest overall match.  If more
981       than  one  match is possible, the one starting closest to the beginning
982       of the string will be chosen.   However, for each of the above compound
983       patterns  a  -  can be inserted in front of the ( to cause the shortest
984       match to the specified pattern-list to be used.
985
986       When pattern-list is contained within parentheses, the backslash  char‐
987       acter  \ is treated specially even when inside a character class.   All
988       ANSI-C character escapes are recognized and match the specified charac‐
989       ter.  In addition the following escape sequences are recognized:
990              \d     Matches any character in the digit class.
991              \D     Matches any character not in the digit class.
992              \s     Matches any character in the space class.
993              \S     Matches any character not in the space class.
994              \w     Matches any character in the word class.
995              \W     Matches any character not in the word class.
996
997       A  pattern  of the form %(pattern-pair(s)) is a sub-pattern that can be
998       used to match nested character expressions.  Each pattern-pair is a two
999       character sequence which cannot contain & or |.  The first pattern-pair
1000       specifies the starting and ending characters for the match.  Each  sub‐
1001       sequent  pattern-pair represents the beginning and ending characters of
1002       a nested group that will be skipped over  when  counting  starting  and
1003       ending  character  matches.  The behavior is unspecified when the first
1004       character of a pattern-pair is alphanumeric except for the following:
1005              D      Causes the ending character to terminate the  search  for
1006                     this pattern without finding a match.
1007              E      Causes  the  ending character to be interpreted as an es‐
1008                     cape character.
1009              L      Causes the ending character to be interpreted as a  quote
1010                     character causing all characters to be ignored when look‐
1011                     ing for a match.
1012              Q      Causes the ending character to be interpreted as a  quote
1013                     character  causing  all  characters other than any escape
1014                     character to be ignored when looking for a match.
1015       Thus, %({}Q"E\), matches characters starting at { until the matching  }
1016       is  found not counting any { or } that is inside a double quoted string
1017       or preceded by the escape character \.  Without  the  {}  this  pattern
1018       matches any C language string.
1019
1020       Each  sub-pattern in a composite pattern is numbered, starting at 1, by
1021       the location of the ( within the pattern.  The sequence \n, where n  is
1022       a  single  digit  and \n comes after the n-th. sub-pattern, matches the
1023       same string as the sub-pattern itself.
1024
1025       Finally a pattern can contain sub-patterns of the  form  ∼(options:pat‐
1026       tern-list),  where either options or :pattern-list can be omitted.  Un‐
1027       like the other compound patterns, these sub-patterns are not counted in
1028       the  numbered  sub-patterns.  :pattern-list must be omitted for options
1029       F, G, N , and V below.  If options is present, it can consist of one or
1030       more of the following:
1031              +      Enable the following options.  This is the default.
1032              -      Disable the following options.
1033              E      The  remainder  of  the pattern uses extended regular ex‐
1034                     pression syntax like the egrep(1) command.
1035              F      The remainder of the  pattern  uses  fgrep(1)  expression
1036                     syntax.
1037              G      The  remainder  of the pattern uses basic regular expres‐
1038                     sion syntax like the grep(1) command.
1039              K      The remainder of the pattern uses shell  pattern  syntax.
1040                     This is the default.
1041              N      This  is  ignored.   However, when it is the first letter
1042                     and is used with file name generation, and no matches oc‐
1043                     cur, the file pattern expands to the empty string.
1044              X      The  remainder  of the pattern uses augmented regular ex‐
1045                     pression syntax like the xgrep(1) command.
1046              P      The remainder of the pattern uses perl(1) regular expres‐
1047                     sion  syntax.   Not all perl regular expression syntax is
1048                     currently implemented.
1049              V      The remainder of the pattern uses System  V  regular  ex‐
1050                     pression syntax.
1051              i      Always treat the match as case-insensitive, regardless of
1052                     the globcasedetect shell option.
1053              g      File the longest match (greedy).  This is the default.
1054              l      Left anchor the pattern.  This is the default for K style
1055                     patterns.
1056              r      Right  anchor  the  pattern.   This  is the default for K
1057                     style patterns.
1058       If both options and :pattern-list are specified, then the options apply
1059       only to  pattern-list.  Otherwise, these options remain in effect until
1060       they are disabled by a subsequent ∼(...) or at the end of the  sub-pat‐
1061       tern containing ∼(...).
1062
1063   Quoting.
1064       Each of the metacharacters listed earlier (see Definitions above) has a
1065       special meaning to the shell and causes termination of  a  word  unless
1066       quoted.   A character may be quoted (i.e., made to stand for itself) by
1067       preceding it with a \.  The pair \new-line is removed.  All  characters
1068       enclosed between a pair of single quote marks (′′) that is not preceded
1069       by a $ are quoted.  A single quote  cannot  appear  within  the  single
1070       quotes.   A single quoted string preceded by an unquoted $ is processed
1071       as an ANSI-C string except for the following:
1072       \0     Causes the remainder of the string to be ignored.
1073       \E     Equivalent to the escape character (ascii 033),
1074       \e     Equivalent to the escape character (ascii 033),
1075       \cx    Expands to the character control-x.
1076       \C[.name.]
1077              Expands to the collating element name.
1078
1079       Inside double quote marks (""), parameter and command substitution  oc‐
1080       cur and \ quotes the characters \, `, ", and $.  A $ in front of a dou‐
1081       ble quoted string will be ignored in the "C" or "POSIX" locale, and may
1082       cause  the string to be replaced by a locale specific string otherwise.
1083       The meaning of $* and $@ is identical when not quoted or when used as a
1084       variable  assignment  value or as a file name.  However, when used as a
1085       command argument, "$*" is equivalent to "$1d$2d...",  where  d  is  the
1086       first character of the IFS variable, whereas "$@" is equivalent to "$1"
1087       "$2" ....  Inside grave quote marks (``), \ quotes the characters \, `,
1088       and  $.   If  the  grave quotes occur within double quotes, then \ also
1089       quotes the character ".
1090
1091       The special meaning of reserved words or  aliases  can  be  removed  by
1092       quoting  any  character of the reserved word.  The recognition of func‐
1093       tion names or built-in command names listed below cannot be altered  by
1094       quoting them.
1095
1096   Arithmetic Evaluation.
1097       The  shell  performs arithmetic evaluation for arithmetic substitution,
1098       to evaluate an arithmetic command, to evaluate an  indexed  array  sub‐
1099       script,  and  to  evaluate arguments to the built-in commands shift and
1100       let.  Evaluations are performed using double precision  floating  point
1101       arithmetic  or  long  double  precision floating point for systems that
1102       provide this data type.  Floating point  constants  follow  the  ANSI-C
1103       programming  language  floating  point conventions.  The floating point
1104       constants Nan and Inf can be used to represent "not a number"  and  in‐
1105       finity  respectively.   Integer constants follow the ANSI-C programming
1106       language integer constant conventions although only single byte charac‐
1107       ter  constants  are  recognized and character casts are not recognized.
1108       In addition constants can be of the form [base#]n where base is a deci‐
1109       mal  number between two and sixty-four representing the arithmetic base
1110       and n is a number in that base.  The digits above 9 are represented  by
1111       the  lower case letters, the upper case letters, @, and _ respectively.
1112       For bases less than or equal to 36, upper and lower case characters can
1113       be used interchangeably.
1114
1115       An arithmetic expression uses the same syntax, precedence, and associa‐
1116       tivity of expression as the C language.  All the C  language  operators
1117       that  apply to floating point quantities can be used.  In addition, the
1118       operator ** can be used for exponentiation.  It has  higher  precedence
1119       than  multiplication  and  is  left associative.  In addition, when the
1120       value of an arithmetic variable or sub-expression can be represented as
1121       a  long  integer,  all  C language integer arithmetic operations can be
1122       performed.  Variables can be referenced by name  within  an  arithmetic
1123       expression  without using the parameter expansion syntax.  When a vari‐
1124       able is referenced, its value is evaluated as an arithmetic expression.
1125
1126       Any of the following math library functions that are in the C math  li‐
1127       brary can be used within an arithmetic expression:
1128
1129       abs  acos acosh asin asinh atan atan2 atanh cbrt ceil copysign cos cosh
1130       erf erfc exp exp10 exp2 expm1 fabs fdim finite  float  floor  fma  fmax
1131       fmin  fmod  fpclass  fpclassify  hypot ilogb int isfinite isgreater is‐
1132       greaterequal isinf isinfinite isless  islessequal  islessgreater  isnan
1133       isnormal issubnormal isunordered iszero j0 j1 jn ldexp lgamma log log10
1134       log1p log2 logb nearbyint nextafter nexttoward pow remainder rint round
1135       scalb scalbn signbit sin sinh sqrt tan tanh tgamma trunc y0 y1 yn
1136
1137       In  addition,  arithmetic  functions  can be defined as shell functions
1138       with a variant of the function name syntax,
1139
1140       function .sh.math.name ident ... { list ;}
1141              where name is the function name used in the  arithmetic  expres‐
1142              sion  and each identifier, ident is a name reference to the long
1143              double  precision  floating  point  argument.   The   value   of
1144              .sh.value  when  the function returns is the value of this func‐
1145              tion.  User defined functions can take up  to  3  arguments  and
1146              override C math library functions.
1147
1148       An internal representation of a variable as a double precision floating
1149       point can be specified with the -E [n], -F [n], or -X [n] option of the
1150       typeset  special  built-in command.  The -E option causes the expansion
1151       of the value to be represented using scientific notation when it is ex‐
1152       panded.   The optional option argument n defines the number of signifi‐
1153       cant figures.  The -F option causes the expansion to be represented  as
1154       a  floating  decimal  number when it is expanded.  The -X option causes
1155       the expansion to be represented using the  %a  format  defined  by  ISO
1156       C-99.   The optional option argument n defines the number of places af‐
1157       ter the decimal (or radix) point in this case.
1158
1159       An internal integer representation of a variable can be specified  with
1160       the  -i  [n]  option  of the typeset special built-in command.  The op‐
1161       tional option argument n specifies an arithmetic base to be  used  when
1162       expanding the variable.  If you do not specify an arithmetic base, base
1163       10 will be used.
1164
1165       Arithmetic evaluation is performed on the value of each assignment to a
1166       variable  with  the  -E, -F, -X, or -i attribute.  Assigning a floating
1167       point number to a variable whose type is an integer  causes  the  frac‐
1168       tional part to be truncated.
1169
1170   Prompting.
1171       When  used interactively, the shell prompts with the value of PS1 after
1172       expanding it for parameter expansion, command substitution, and  arith‐
1173       metic substitution, before reading a command.  In addition, each single
1174       !  in the prompt is replaced by the command number.  A !!  is  required
1175       to place !  in the prompt.  If at any time a new-line is typed and fur‐
1176       ther input is needed to complete a command, then the  secondary  prompt
1177       (i.e., the value of PS2) is issued.
1178
1179   Conditional Expressions.
1180       A  conditional  expression is used with the [[ compound command to test
1181       attributes of files and to compare strings.  Field splitting  and  file
1182       name generation are not performed on the words between [[ and ]].  Each
1183       expression can be constructed from one or more of the  following  unary
1184       or binary expressions:
1185       string True, if string is not null.
1186       -a file
1187              Same as -e below.  This is obsolete.
1188       -b file
1189              True, if file exists and is a block special file.
1190       -c file
1191              True, if file exists and is a character special file.
1192       -d file
1193              True, if file exists and is a directory.
1194       -e file
1195              True, if file exists.
1196       -f file
1197              True, if file exists and is an ordinary file.
1198       -g file
1199              True, if file exists and it has its setgid bit set.
1200       -k file
1201              True, if file exists and it has its sticky bit set.
1202       -n string
1203              True, if length of string is non-zero.
1204       -o ?option
1205              True, if option named option is a valid option name.
1206       -o option
1207              True, if option named option is on.
1208       -p file
1209              True, if file exists and is a fifo special file or a pipe.
1210       -r file
1211              True, if file exists and is readable by current process.
1212       -s file
1213              True, if file exists and has size greater than zero.
1214       -t fildes
1215              True,  if  file  descriptor number fildes is open and associated
1216              with a terminal device.
1217       -u file
1218              True, if file exists and it has its setuid bit set.
1219       -v name
1220              True, if variable name is a valid variable name and is set.
1221       -w file
1222              True, if file exists and is writable by current process.
1223       -x file
1224              True, if file exists and is executable by current  process.   If
1225              file exists and is a directory, then true if the current process
1226              has permission to search in the directory.
1227       -z string
1228              True, if length of string is zero.
1229       -L file
1230              True, if file exists and is a symbolic link.
1231       -h file
1232              True, if file exists and is a symbolic link.
1233       -N file
1234              True, if file exists and the modification time is  greater  than
1235              the last access time.
1236       -O file
1237              True,  if  file  exists and is owned by the effective user id of
1238              this process.
1239       -G file
1240              True, if file exists and its group matches the  effective  group
1241              id of this process.
1242       -R name
1243              True if variable name is a name reference.
1244       -S file
1245              True, if file exists and is a socket.
1246       file1 -nt file2
1247              True, if file1 exists and file2 does not, or file1 is newer than
1248              file2.
1249       file1 -ot file2
1250              True, if file2 exists and file1 does not, or file1 is older than
1251              file2.
1252       file1 -ef file2
1253              True, if file1 and file2 exist and refer to the same file.
1254       string == pattern
1255              True,  if  string  matches  pattern.  Any part of pattern can be
1256              quoted to cause it to be matched as a string.  With a successful
1257              match  to  a  pattern, the .sh.match array variable will contain
1258              the match and sub-pattern matches.
1259       string = pattern
1260              Same as == above, but is obsolete.
1261       string != pattern
1262              True, if string does not match pattern.  When the string matches
1263              the  pattern the .sh.match array variable will contain the match
1264              and sub-pattern matches.
1265       string =∼ ere
1266              True if string matches the pattern ∼(E)ere where ere is  an  ex‐
1267              tended regular expression.
1268       string1 < string2
1269              True,  if  string1  comes before string2 based on ASCII value of
1270              their characters.
1271       string1 > string2
1272              True, if string1 comes after string2 based  on  ASCII  value  of
1273              their characters.
1274       The following obsolete arithmetic comparisons are also permitted:
1275       exp1 -eq exp2
1276              True, if exp1 is equal to exp2.
1277       exp1 -ne exp2
1278              True, if exp1 is not equal to exp2.
1279       exp1 -lt exp2
1280              True, if exp1 is less than exp2.
1281       exp1 -gt exp2
1282              True, if exp1 is greater than exp2.
1283       exp1 -le exp2
1284              True, if exp1 is less than or equal to exp2.
1285       exp1 -ge exp2
1286              True, if exp1 is greater than or equal to exp2.
1287
1288       In  each  of  the  above expressions, if file is of the form /dev/fd/n,
1289       where n is an integer, then the test is applied to the open file  whose
1290       descriptor number is n.
1291
1292       A compound expression can be constructed from these primitives by using
1293       any of the following, listed in decreasing order of precedence.
1294       (expression)
1295              True, if expression is true.  Used to group expressions.
1296       ! expression
1297              True if expression is false.
1298       expression1 && expression2
1299              True, if expression1 and expression2 are both true.
1300       expression1 || expression2
1301              True, if either expression1 or expression2 is true.
1302
1303   Input/Output.
1304       Before a command is executed, its input and output  may  be  redirected
1305       using  a  special notation interpreted by the shell.  The following may
1306       appear anywhere in a simple-command or may precede or follow a  command
1307       and  are  not  passed on to the invoked command.  Command substitution,
1308       parameter expansion, and arithmetic substitution occur before  word  or
1309       digit  is used except as noted below.  File name generation occurs only
1310       if the shell is interactive and the  pattern  matches  a  single  file.
1311       Field splitting is not performed.
1312
1313       In  each  of  the  following  redirections,  if  file  is  of  the form
1314       /dev/sctp/host/port, /dev/tcp/host/port, or  /dev/udp/host/port,  where
1315       host is a hostname or host address, and port is a service given by name
1316       or an integer port number, then the redirection attempts to make a tcp,
1317       sctp or udp connection to the corresponding socket.
1318
1319       No  intervening  space is allowed between the characters of redirection
1320       operators.
1321
1322       <word         Use file word as standard input (file descriptor 0).
1323
1324       >word         Use file word as standard output (file descriptor 1).  If
1325                     the  file does not exist then it is created.  If the file
1326                     exists, and the noclobber option is on,  this  causes  an
1327                     error; otherwise, it is truncated to zero length.
1328
1329       >|word        Same as >, except that it overrides the noclobber option.
1330
1331       >;word        Write  output  to  a temporary file.  If the command com‐
1332                     pletes successfully rename it to word, otherwise,  delete
1333                     the  temporary file.  >;word cannot be used with the exec
1334                     and redirect built-ins.
1335
1336       >>word        Use file word as standard output.  If  the  file  exists,
1337                     then  output  is  appended to it (by first seeking to the
1338                     end-of-file); otherwise, the file is created.
1339
1340       <>word        Open file word for reading and writing as  standard  out‐
1341                     put.  If the posix option is active, it defaults to stan‐
1342                     dard input instead.
1343
1344       <>;word       The same as <>word except that if the  command  completes
1345                     successfully,  word is truncated to the offset at command
1346                     completion.  <>;word cannot be used with the exec and re‐
1347                     direct built-ins.
1348
1349       <<[-]word     The  shell input is read up to a line that is the same as
1350                     word after any quoting has been removed, or to an end-of-
1351                     file.   No  parameter substitution, command substitution,
1352                     arithmetic substitution or file name generation  is  per‐
1353                     formed  on  word.  The resulting document, called a here-
1354                     document, becomes the standard input.  If  any  character
1355                     of  word is quoted, then no interpretation is placed upon
1356                     the characters of the document; otherwise, parameter  ex‐
1357                     pansion,  command  substitution, and arithmetic substitu‐
1358                     tion occur, \new-line is ignored, and \ must be  used  to
1359                     quote  the  characters  \, $, `.  If - is appended to <<,
1360                     then all leading tabs are stripped from word and from the
1361                     document.   If  #  is appended to <<, then leading spaces
1362                     and tabs will be stripped off the first line of the docu‐
1363                     ment and up to an equivalent indentation will be stripped
1364                     from the remaining lines and from word.  A  tab  stop  is
1365                     assumed  to  occur at every 8 columns for the purposes of
1366                     determining the indentation.
1367
1368       <<<word       A short form of here document in which word  becomes  the
1369                     contents  of the here-document after any parameter expan‐
1370                     sion, command substitution, and  arithmetic  substitution
1371                     occur.
1372
1373       <&digit       The  standard  input  is  duplicated from file descriptor
1374                     digit (see dup(2)).
1375
1376       >&digit       The standard output is duplicated  from  file  descriptor
1377                     digit.
1378
1379       <&digit-      The  file  descriptor given by digit is moved to standard
1380                     input.
1381
1382       >&digit-      The file descriptor given by digit is moved  to  standard
1383                     output.
1384
1385       <&-           The standard input is closed.
1386
1387       >&-           The standard output is closed.
1388
1389       <&p           The input from the co-process is moved to standard input.
1390
1391       >&p           The output to the co-process is moved to standard output.
1392
1393       <#((expr))    Evaluate arithmetic expression expr and position file de‐
1394                     scriptor 0 to the resulting value bytes from the start of
1395                     the file.  The variables CUR and EOF evaluate to the cur‐
1396                     rent offset  and  end-of-file  offset  respectively  when
1397                     evaluating expr.
1398
1399       >#((offset))  The same as <# except applies to file descriptor 1.
1400
1401       <#pattern     Seeks  forward to the beginning of the next line contain‐
1402                     ing pattern.
1403
1404       <##pattern    The same as <# except that the portion of the  file  that
1405                     is skipped is copied to standard output.
1406
1407       If  one of the above is preceded by a digit, with no intervening space,
1408       then the file descriptor number referred to is that  specified  by  the
1409       digit (instead of the default 0 or 1).  If one of the above, other than
1410       >&- and the ># and <# forms, is preceded by {varname} with no interven‐
1411       ing  space,  then  a file descriptor number > 9 will be selected by the
1412       shell and stored in the variable varname, so it can  be  read  from  or
1413       written  to  with redirections like <& $varname or >& $varname.  If >&-
1414       or the any of the ># and <# forms is preceded by {varname} the value of
1415       varname defines the file descriptor to close or position.  For example:
1416
1417              ... 2>&1
1418
1419       means  file  descriptor 2 is to be opened for writing as a duplicate of
1420       file descriptor 1 and
1421
1422              exec {n}<file
1423
1424       means open file named file for reading and store  the  file  descriptor
1425       number in variable n.
1426
1427       A  special  shorthand  redirection  operator &>word is available; it is
1428       equivalent to >word 2>&1. It cannot be preceded by any digit  or  vari‐
1429       able  name. This shorthand is disabled if the posix shell option is ac‐
1430       tive.
1431
1432       The order in which redirections  are  specified  is  significant.   The
1433       shell  evaluates  each  redirection  in  terms of the (file descriptor,
1434       file) association at the time of evaluation.  For example:
1435
1436              ... 1>fname 2>&1
1437
1438       first associates file descriptor 1 with file fname.  It then associates
1439       file descriptor 2 with the file associated with file descriptor 1 (i.e.
1440       fname).  If the order of redirections were reversed, file descriptor  2
1441       would  be  associated with the terminal (assuming file descriptor 1 had
1442       been) and then file descriptor 1 would be associated with file fname.
1443
1444       If a command is followed by & and job control is not active,  then  the
1445       default  standard  input  for  the command is the empty file /dev/null.
1446       Otherwise, the environment for the execution of a command contains  the
1447       file  descriptors  of  the  invoking  shell as modified by input/output
1448       specifications.
1449
1450   Environment.
1451       The environment (see environ(7)) is a list of name-value pairs that  is
1452       passed  to  an  executed  program  in the same way as a normal argument
1453       list.  The names must be  identifiers  and  the  values  are  character
1454       strings.  The shell interacts with the environment in several ways.  On
1455       invocation, the shell scans the environment and creates a variable  for
1456       each  name  found, giving it the corresponding value and attributes and
1457       marking it export.  Executed commands inherit the environment.  If  the
1458       user  modifies the values of these variables or creates new ones, using
1459       the export or typeset -x commands, they become part of the environment.
1460       The  environment  seen  by any executed command is thus composed of any
1461       name-value pairs originally inherited by the shell, whose values may be
1462       modified  by  the current shell, plus any additions which must be noted
1463       in export or typeset -x commands.
1464
1465       The environment for any simple-command or function may be augmented  by
1466       prefixing it with one or more variable assignments.  A variable assign‐
1467       ment argument is a word of the form identifier=value.  Thus:
1468
1469              TERM=450 cmd args                  and
1470              (export TERM; TERM=450; cmd args)
1471
1472       are equivalent (as far as the above execution of cmd is  concerned  ex‐
1473       cept for special built-in commands listed below - those that are marked
1474       with ).
1475
1476       If the obsolete -k option is set, all variable assignment arguments are
1477       placed  in  the environment, even if they occur after the command name.
1478       The following first prints a=b c and then c:
1479
1480              echo a=b c
1481              set -k
1482              echo a=b c
1483       This feature is intended for use with scripts written  for  early  ver‐
1484       sions  of the shell and its use in new scripts is strongly discouraged.
1485       It is likely to disappear someday.
1486
1487   Functions.
1488       For historical reasons, there are two ways  to  define  functions,  the
1489       name()  syntax  and the function name syntax, described in the Commands
1490       section above.  Shell functions are  read  in  and  stored  internally.
1491       Alias names are resolved when the function is read.  Functions are exe‐
1492       cuted like commands with the arguments passed as positional parameters.
1493       (See Execution below.)
1494
1495       Functions  defined  by the function name syntax and called by name exe‐
1496       cute in the same process as the caller and share all files and  present
1497       working  directory with the caller.  Traps caught by the caller are re‐
1498       set to their default action inside the function.  A trap condition that
1499       is  not caught or ignored by the function causes the function to termi‐
1500       nate and the condition to be passed on to the caller.  A trap  on  EXIT
1501       set  inside a function is executed in the environment of the caller af‐
1502       ter the function completes.  Ordinarily, variables are  shared  between
1503       the  calling  program  and  the function.  However, the typeset special
1504       built-in command used within a function defines local  variables  whose
1505       scope  includes  the current function.  They can be passed to functions
1506       that they call in the variable assignment list that precedes  the  call
1507       or as arguments passed as name references.  Errors within functions re‐
1508       turn control to the caller.
1509
1510       Functions defined with the name() syntax and functions defined with the
1511       function  name syntax that are invoked with the .  special built-in are
1512       executed in the caller's environment and share all variables and  traps
1513       with  the  caller.   Errors  within these function executions cause the
1514       script that contains them to abort.
1515
1516       The special built-in command return is used  to  return  from  function
1517       calls.
1518
1519       Function  names  can  be listed with the -f or +f option of the typeset
1520       special built-in command.  The text of functions, when available,  will
1521       also  be listed with -f.  Functions can be undefined with the -f option
1522       of the unset special built-in command.
1523
1524       Ordinarily, functions are unset when the shell executes a shell script.
1525       Functions  that  need  to be defined across separate invocations of the
1526       shell should be placed in a directory and  the  FPATH  variable  should
1527       contain  the name of this directory.  They may also be specified in the
1528       ENV file.
1529
1530   Discipline Functions.
1531       Each variable can have zero or  more  discipline  functions  associated
1532       with  it.   The  shell  initially understands the discipline names get,
1533       set, append, and unset but can be added when defining  new  types.   On
1534       most  systems others can be added at run time via the C programming in‐
1535       terface extension provided by the builtin built-in utility.  If the get
1536       discipline  is defined for a variable, it is invoked whenever the given
1537       variable is referenced.  If the variable .sh.value is assigned a  value
1538       inside  the  discipline function, the referenced variable will evaluate
1539       to this value instead.  If the set discipline is defined  for  a  vari‐
1540       able,  it  is  invoked whenever the given variable is assigned a value.
1541       If the append discipline is defined for a variable, it is invoked when‐
1542       ever a value is appended to the given variable.  The variable .sh.value
1543       is given the value of the variable before invoking the discipline,  and
1544       the  variable  will be assigned the value of .sh.value after the disci‐
1545       pline completes.  If .sh.value is unset  inside  the  discipline,  then
1546       that  value  is  unchanged.   If  the unset discipline is defined for a
1547       variable, it is invoked whenever the  given  variable  is  unset.   The
1548       variable  will  not  be unset unless it is unset explicitly from within
1549       this discipline function.
1550
1551       The variable .sh.name contains the name of the variable for  which  the
1552       discipline  function  is  called, .sh.subscript is the subscript of the
1553       variable, and .sh.value will contain the value  being  assigned  inside
1554       the  set  discipline  function.   The  variable _ is a reference to the
1555       variable including the subscript  if  any.   For  the  set  discipline,
1556       changing  .sh.value will change the value that gets assigned.  Finally,
1557       the expansion ${var.name}, when name is the name of a  discipline,  and
1558       there is no variable of this name, is equivalent to the command substi‐
1559       tution ${ var.name;}.
1560
1561
1562   Name Spaces.
1563       Commands and functions that are executed as part of the list of a name‐
1564       space  command  that  modify variables or create new ones, create a new
1565       variable whose name is the name of the name space as given  by  identi‐
1566       fier  preceded by ..  When a variable whose name is name is referenced,
1567       it is first searched for using .identifier.name.  Similarly, a function
1568       defined  by  a  command in the namespace list is created using the name
1569       space name preceded by a ..
1570
1571       When  the list of a namespace command contains a namespace command, the
1572       names  of variables and functions that are created consist of the vari‐
1573       able or function name preceded by the list of identifiers each preceded
1574       by ..
1575
1576       Outside  of  a name space, a variable or function created inside a name
1577       space can be referenced by preceding it with the name space name.
1578
1579       By default, variables staring with .sh are in the sh name space.
1580
1581
1582   Type Variables.
1583       Typed variables provide a way to create data structure and objects.   A
1584       type  can  be  defined either by a shared library, by the enum built-in
1585       command described below, or by using the new -T option of  the  typeset
1586       built-in command.  With the -T option of typeset, the type name, speci‐
1587       fied as an option argument to -T, is set with a compound  variable  as‐
1588       signment that defines the type.  Function definitions can appear inside
1589       the compound variable assignment and these become discipline  functions
1590       for  this  type and can be invoked or redefined by each instance of the
1591       type.  The function name create is treated specially.   It  is  invoked
1592       for  each instance of the type that is created but is not inherited and
1593       cannot be redefined for each instance.
1594
1595       When a type is defined a special  built-in  command  of  that  name  is
1596       added.   These  built-ins  are declaration commands and follow the same
1597       expansion rules as the  built-in  commands  described  below  that  are
1598       marked  with a ‡ symbol. These commands can subsequently be used inside
1599       further type definitions.  The man page for these commands can be  gen‐
1600       erated  by  using  the  --man option or any of the other -- options de‐
1601       scribed with getopts.  The -r, -a, -A, -h, and -S  options  of  typeset
1602       are permitted with each of these new built-ins.
1603
1604       An  instance of a type is created by invoking the type name followed by
1605       one or more instance names.  Each instance of the type  is  initialized
1606       with  a copy of the sub-variables except for sub-variables that are de‐
1607       fined with the -S option.  Variables defined with the -S are shared  by
1608       all  instances  of the type.  Each instance can change the value of any
1609       sub-variable and can also define new discipline functions of  the  same
1610       names  as  those defined by the type definition as well as any standard
1611       discipline names.  No additional sub-variables can be defined  for  any
1612       instance.
1613
1614       When defining a type, if the value of a sub-variable is not set and the
1615       -r attribute is specified, it causes the sub-variable to be a  required
1616       sub-variable.   Whenever an instance of a type is created, all required
1617       sub-variables must be specified.  These sub-variables  become  readonly
1618       in each instance.
1619
1620       When  unset  is invoked on a sub-variable within a type, and the -r at‐
1621       tribute has not been specified for this field, the value  is  reset  to
1622       the  default value associative with the type.  Invoking unset on a type
1623       instance not contained within another type  deletes  all  sub-variables
1624       and the variable itself.
1625
1626       A type definition can be derived from another type definition by defin‐
1627       ing the first sub-variable name as _ and defining its type as the  base
1628       type.   Any  remaining  definitions will be additions and modifications
1629       that apply to the new type.  If the new type name is the same  as  that
1630       of  the base type, the type will be replaced and the original type will
1631       no longer be accessible.
1632
1633       The typeset command with the -T and no option argument or operands will
1634       write all the type definitions to standard output in a form that can be
1635       read in to create all they types.
1636
1637   Jobs.
1638       If the monitor option of the set command is turned on,  an  interactive
1639       shell associates a job with each pipeline.  It keeps a table of current
1640       jobs, printed by the jobs command, and assigns them small integer  num‐
1641       bers.   When a job is started asynchronously with &, the shell prints a
1642       line which looks like:
1643
1644            [1] 1234
1645
1646       indicating that the job which was started asynchronously was job number
1647       1 and had one (top-level) process, whose process id was 1234.
1648
1649       This  paragraph  and the next require features that are not in all ver‐
1650       sions of UNIX and may not apply.  If you are running a job and wish  to
1651       do something else you may hit the key ^Z (control-Z) which sends a STOP
1652       signal to the current job.  The shell will then normally indicate  that
1653       the job has been `Stopped', and print another prompt.  You can then ma‐
1654       nipulate the state of this job, putting it in the background  with  the
1655       bg  command,  or  run some other commands and then eventually bring the
1656       job back into the foreground with the  foreground  command  fg.   A  ^Z
1657       takes  effect immediately and is like an interrupt in that pending out‐
1658       put and unread input are discarded when it is typed.
1659
1660       A job being run in the background will stop if it tries  to  read  from
1661       the  terminal.  Background jobs are normally allowed to produce output,
1662       but this can be disabled by giving the command stty tostop.  If you set
1663       this  tty  option, then background jobs will stop when they try to pro‐
1664       duce output like they do when they try to read input.
1665
1666       A job pool is a collection of jobs started with list & associated  with
1667       a name.
1668
1669       There are several ways to refer to jobs in the shell.  A job can be re‐
1670       ferred to by the process id of any process of the job or by one of  the
1671       following:
1672       %number
1673              The job with the given number.
1674       pool   All the jobs in the job pool named by pool.
1675       pool.number
1676              The job number number in the job pool named by pool.
1677       %string
1678              Any job whose command line begins with string.
1679       %?string
1680              Any job whose command line contains string.
1681       %%     Current job.
1682       %+     Equivalent to %%.
1683       %-     Previous  job.   In addition, unless noted otherwise, wherever a
1684              job can be specified, the name of a background job pool  can  be
1685              used to represent all the jobs in that pool.
1686
1687       The shell learns immediately whenever a process changes state.  It nor‐
1688       mally informs you whenever a job becomes blocked  so  that  no  further
1689       progress is possible, but only just before it prints a prompt.  This is
1690       done so that it does not otherwise disturb your work.  The  notify  op‐
1691       tion of the set command causes the shell to print these job change mes‐
1692       sages as soon as they occur.
1693
1694       When the monitor option is on, each background job that completes trig‐
1695       gers any trap set for CHLD.
1696
1697       When  you try to leave the shell while jobs are running or stopped, you
1698       will be warned that `You have stopped(running) jobs.'  You may use  the
1699       jobs  command  to  see  what  they are.  If you immediately try to exit
1700       again, the shell will not warn you a second time, and the stopped  jobs
1701       will be terminated.  When a login shell receives a HUP signal, it sends
1702       a HUP signal to each job that has not been  disowned  with  the  disown
1703       built-in command described below.
1704
1705   Signals.
1706       The INT and QUIT signals for an invoked command are ignored if the com‐
1707       mand is followed by & and the monitor option is not active.  Otherwise,
1708       signals have the values inherited by the shell from its parent (but see
1709       also the trap built-in command below).
1710
1711   Execution.
1712       Each time a command is read, the above substitutions are  carried  out.
1713       If the command name matches one of the Special Built-in Commands listed
1714       below, it is executed within the current shell process.  Next, the com‐
1715       mand  name is checked to see if it matches a user defined function.  If
1716       it does, the positional parameters are saved and then reset to the  ar‐
1717       guments  of the function call.  A function is also executed in the cur‐
1718       rent shell process.  When the function completes or  issues  a  return,
1719       the  positional parameter list is restored.  For functions defined with
1720       the function name syntax, any trap set on EXIT within the  function  is
1721       executed.   The  exit value of a function is the value of the last com‐
1722       mand executed.  If a command name is not a special built-in command  or
1723       a  user defined function, but it is one of the built-in commands listed
1724       below, it is executed in the current shell process.
1725
1726       The shell variables PATH followed by the  variable  FPATH  defines  the
1727       list of directories to search for the command name.  Alternative direc‐
1728       tory names are separated by a colon (:).  The default path is the value
1729       that was output by getconf PATH at the time ksh was compiled.  The cur‐
1730       rent directory can be specified by two or more adjacent colons, or by a
1731       colon  at  the  beginning or end of the path list.  If the command name
1732       contains a /, then the search path is not used.  Otherwise, each direc‐
1733       tory in the list of directories defined by PATH and FPATH is checked in
1734       order.  If the directory being searched is contained in FPATH and  con‐
1735       tains  a  file whose name matches the command being searched, then this
1736       file is loaded into the current shell environment as if it were the ar‐
1737       gument  to  the . command except that only preset aliases are expanded,
1738       and a function of the given name is executed as described above.
1739
1740       If this directory is not in FPATH the shell  first  determines  whether
1741       there is a built-in version of a command corresponding to a given path‐
1742       name and if so it is invoked in the current process.  If no built-in is
1743       found,  the shell checks for a file named .paths in this directory.  If
1744       found and there is a line of the form FPATH=path where  path  names  an
1745       existing  directory  then  that directory is searched immediately after
1746       the current directory as if it were found in the  FPATH  variable.   If
1747       path does not begin with /, it is checked for relative to the directory
1748       being searched.
1749
1750       The .paths file is then checked for a line of the form  PLUGIN_LIB=lib‐
1751       name  [  :  libname  ]  ...  .   Each  library named by libname will be
1752       searched for as if it were an option argument to builtin -f, and if  it
1753       contains a built-in of the specified name this will be executed instead
1754       of a command by this name.  Any built-in loaded from  a  library  found
1755       this  way  will  be associated with the directory containing the .paths
1756       file so it will only execute if not found in an earlier directory.
1757
1758       Finally, the directory will be checked for a file of  the  given  name.
1759       If  the file has execute permission but is not an a.out file, it is as‐
1760       sumed to be a file containing shell  commands.   A  separate  shell  is
1761       spawned  to  read  it.   All non-exported variables are removed in this
1762       case.  If the shell command file doesn't have read  permission,  or  if
1763       the  setuid and/or setgid bits are set on the file, then the shell exe‐
1764       cutes an agent whose job it is to set up the  permissions  and  execute
1765       the  shell with the shell command file passed down as an open file.  If
1766       the .paths contains a line of the form name=value in the first or  sec‐
1767       ond  line, then the environment variable name is modified by prepending
1768       the directory specified by value to the directory list.   If  value  is
1769       not  an  absolute  directory, then it specifies a directory relative to
1770       the directory that the executable was found.  If the environment  vari‐
1771       able  name  does  not already exist it will be added to the environment
1772       list for the specified command.  A parenthesized command is executed in
1773       a subshell without removing non-exported variables.
1774
1775   Command Re-entry.
1776       The  text  of  the  last HISTSIZE (default 512) commands entered from a
1777       terminal device is saved in a history file.  The file $HOME/.sh_history
1778       is  used if the HISTFILE variable is not set or if the file it names is
1779       not writable.  A shell can  access  the  commands  of  all  interactive
1780       shells which use the same named HISTFILE.  The built-in command hist is
1781       used to list or edit a portion of this file.  The portion of  the  file
1782       to be edited or listed can be selected by number or by giving the first
1783       character or characters of the command.  A single command or  range  of
1784       commands  can be specified.  If you do not specify an editor program as
1785       an argument to hist then the value of the variable  HISTEDIT  is  used.
1786       If  HISTEDIT is unset, the obsolete variable FCEDIT is used.  If FCEDIT
1787       is not defined, then /bin/ed is used.  The edited command(s) is printed
1788       and  re-executed  upon leaving the editor unless you quit without writ‐
1789       ing.  The -s option (and in obsolete versions, the editor  name  -)  is
1790       used  to skip the editing phase and to re-execute the command.  In this
1791       case a substitution parameter of the form old=new can be used to modify
1792       the  command  before  execution.  For example, with the preset alias r,
1793       which is aliased to ′hist -s′, typing `r bad=good  c'  will  re-execute
1794       the  most  recent command which starts with the letter c, replacing the
1795       first occurrence of the string bad with the string good.
1796
1797   In-line Editing Options.
1798       Normally, each command line entered from a terminal  device  is  simply
1799       typed  followed by a new-line (`RETURN' or `LINE FEED').  If either the
1800       emacs, gmacs, or vi option is active, the user  can  edit  the  command
1801       line.   To  be  in either of these edit modes set the corresponding op‐
1802       tion.  An editing option is automatically selected each time the VISUAL
1803       or EDITOR variable is assigned a value ending in either of these option
1804       names.
1805
1806       The editing features require that the user's terminal  accept  `RETURN'
1807       as  carriage return without line feed and that a space (` ') must over‐
1808       write the current character on the screen.
1809
1810       Unless the multiline option is on, the editing modes implement  a  con‐
1811       cept  where  the  user is looking through a window at the current line.
1812       The window width is the value of COLUMNS if it  is  defined,  otherwise
1813       80.   If  the window width is too small to display the prompt and leave
1814       at least 8 columns to enter input, the prompt  is  truncated  from  the
1815       left.  If the line is longer than the window width minus two, a mark is
1816       displayed at the end of the window to notify the user.  As  the  cursor
1817       moves  and  reaches  the  window boundaries the window will be centered
1818       about the cursor.  The mark is a > (<, *) if the line  extends  on  the
1819       right (left, both) side(s) of the window.
1820
1821       The  search  commands  in  each edit mode provide access to the history
1822       file.  Only strings are matched, not patterns, although a leading ^  in
1823       the  string  restricts the match to begin at the first character in the
1824       line.
1825
1826       Each of the edit modes has an operation to list the files  or  commands
1827       that match a partially entered word.  When applied to the first word on
1828       the line, or the first word after a ;, |, &, or (, and  the  word  does
1829       not  begin  with  or contain a /, the list of aliases, functions, and
1830       executable commands defined by the PATH variable that could  match  the
1831       partial word is displayed.  Otherwise, the list of files that match the
1832       given word is displayed.  If the partially entered word does  not  con‐
1833       tain  any  file expansion characters, a * is appended before generating
1834       these lists.  After displaying the generated list, the  input  line  is
1835       redrawn.   These  operations  are  called command name listing and file
1836       name listing, respectively.  There are additional operations,  referred
1837       to  as  command name completion and file name completion, which compute
1838       the list of matching commands or files, but  instead  of  printing  the
1839       list,  replace  the current word with a complete or partial match.  For
1840       file name completion, if the match is unique, a / is  appended  if  the
1841       file is a directory and a space is appended if the file is not a direc‐
1842       tory.  Otherwise, the longest common prefix for all the matching  files
1843       replaces  the  word.   For command name completion, only the portion of
1844       the file names after the last / are used to find  the  longest  command
1845       prefix.   If  only  a single name matches this prefix, then the word is
1846       replaced with the command name followed by a space.  When using  a  tab
1847       for  completion  that  does  not yield a unique match, a subsequent tab
1848       will provide a numbered list of matching alternatives.  A specific  se‐
1849       lection can be made by entering the selection number followed by a tab.
1850
1851   Key Bindings.
1852       The  KEYBD  trap  can  be  used to intercept keys as they are typed and
1853       change the characters that are actually seen by the shell.   This  trap
1854       is  executed  after  each character (or sequence of characters when the
1855       first character is ESC) is entered while reading from a terminal.   The
1856       variable  .sh.edchar contains the character or character sequence which
1857       generated the trap.  Changing the value of .sh.edchar in the  trap  ac‐
1858       tion  causes  the shell to behave as if the new value were entered from
1859       the keyboard rather than the original value.
1860
1861       The variable .sh.edcol is set to the input column number of the  cursor
1862       at  the  time of the input.  The variable .sh.edmode is set to ESC when
1863       in vi insert mode (see below) and is  null  otherwise.   By  prepending
1864       ${.sh.editmode}  to  a  value  assigned to .sh.edchar it will cause the
1865       shell to change to control mode if it is not already in this mode.
1866
1867       This trap is not invoked for characters entered as arguments to editing
1868       directives, or while reading input for a character search.
1869
1870   Emacs Editing Mode.
1871       This mode is entered by enabling either the emacs or gmacs option.  The
1872       only difference between these two modes is the way they handle ^T.   To
1873       edit,  the  user  moves  the cursor to the point needing correction and
1874       then inserts or deletes characters or words as needed.  All the editing
1875       commands  are control characters or escape sequences.  The notation for
1876       control characters is caret (^) followed by the character.   For  exam‐
1877       ple,  ^F  is the notation for control F.  This is entered by depressing
1878       `f' while holding down the `CTRL' (control) key.  The  `SHIFT'  key  is
1879       not depressed.  (The notation ^?  indicates the DEL (delete) key.)
1880
1881       The  notation  for escape sequences is M- followed by a character.  For
1882       example, M-f (pronounced Meta f) is entered by  depressing  ESC  (ascii
1883       033)  followed  by `f'.  (M-F would be the notation for ESC followed by
1884       `SHIFT' (capital) `F'.)
1885
1886       All edit commands operate from any place on the line (not just  at  the
1887       beginning).   Neither  the  `RETURN' nor the `LINE FEED' key is entered
1888       after edit commands except when noted.
1889
1890       The M-[ multi-character commands below are DEC VT220  escape  sequences
1891       generated  by  special keys on standard PC keyboards, such as the arrow
1892       keys.  You could type them directly but they are meant to recognize the
1893       keys in question, which are indicated in parentheses.
1894
1895       ^F        Move cursor forward (right) one character.
1896       M-[C      (Right arrow) Same as ^F.
1897       M-f       Move  cursor forward one word.  (The emacs editor's idea of a
1898                 word is a string of characters consisting  of  only  letters,
1899                 digits and underscores.)
1900       ^B        Move cursor backward (left) one character.
1901       M-[D      (Left arrow) Same as ^B.
1902       M-b       Move cursor backward one word.
1903       ^A        Move cursor to start of line.
1904       M-[H      (Home) Same as ^A.
1905       ^E        Move cursor to end of line.
1906       M-[F      (End) Same as ^E.
1907       M-[Y      Same as ^E.
1908       ^]char    Move cursor forward to character char on current line.
1909       M-^]char  Move cursor backward to character char on current line.
1910       ^X^X      Interchange the cursor and mark.
1911       erase     (User  defined erase character as defined by the stty(1) com‐
1912                 mand, usually ^H .)  Delete previous character.
1913       lnext     (User defined  literal  next  character  as  defined  by  the
1914                 stty(1)  command,  or  ^V  if not defined.)  Removes the next
1915                 character's editing features (if any).
1916       ^D        Delete current character.
1917       M-[3~     (Forward delete) Same as ^D.
1918       M-d       Delete current word.
1919       M-^H      (Meta-backspace) Delete previous word.
1920       M-h       Delete previous word.
1921       M-^?      (Meta-DEL) Delete previous word (if your interrupt  character
1922                 is ^?  (DEL, the default) then this command will not work).
1923       ^T        Transpose  current  character with previous character and ad‐
1924                 vance the cursor in emacs mode.  Transpose two previous char‐
1925                 acters in gmacs mode.
1926       ^C        Capitalize current character.
1927       M-c       Capitalize current word.
1928       M-l       Change the current word to lower case.
1929       ^K        Delete  from  the cursor to the end of the line.  If preceded
1930                 by a numerical parameter whose value is less than the current
1931                 cursor  position,  then  delete from given position up to the
1932                 cursor.  If preceded by a numerical parameter whose value  is
1933                 greater  than  the  current cursor position, then delete from
1934                 cursor up to given cursor position.
1935       ^W        Kill from the cursor to the mark.
1936       M-p       Push the region from the cursor to the mark on the stack.
1937       kill      (User defined kill character as defined by the stty  command,
1938                 usually  ^U  .)   Kill  the entire current line.  If two kill
1939                 characters are entered in  succession,  all  kill  characters
1940                 from  then on cause a line feed (useful when using paper ter‐
1941                 minals).  A subsequent pair of kill  characters  undoes  this
1942                 change.
1943       ^Y        Restore  last  item removed from line. (Yank item back to the
1944                 line.)
1945       ^L        Line feed and print current line.
1946       M-^L      Clear the screen.
1947       ^@        (Null character) Set mark.
1948       M-space   (Meta space) Set mark.
1949       ^J        (New line) Execute the current line.
1950       ^M        (Return) Execute the current line.
1951       eof       End-of-file character, normally ^D, is processed as  an  End-
1952                 of-file only if the current line is null.
1953       ^P        Fetch previous command.  Each time ^P is entered the previous
1954                 command back in time is accessed.  Moves back one  line  when
1955                 not on the first line of a multi-line command.
1956       M-[A      (Up  arrow)  If  the  cursor is at the end of the line, it is
1957                 equivalent to ^R with string set to the contents of the  cur‐
1958                 rent line.  Otherwise, it is equivalent to ^P.
1959       M-<       Fetch the least recent (oldest) history line.
1960       M->       Fetch the most recent (youngest) history line.
1961       ^N        Fetch  next  command  line.  Each time ^N is entered the next
1962                 command line forward in time is accessed.
1963       M-[B      (Down arrow) Equivalent to ^N.
1964       ^Rstring  Reverse search history for a previous command line containing
1965                 string.   If a parameter of zero is given, the search is for‐
1966                 ward.  String is terminated by a `RETURN' or `NEW LINE'.   If
1967                 string  is  preceded by a ^, the matched line must begin with
1968                 string.  If string is omitted, then  the  next  command  line
1969                 containing  the most recent string is accessed.  In this case
1970                 a parameter of zero reverses the direction of the search.
1971       ^O        Operate - Execute the current line and fetch  the  next  line
1972                 relative to current line from the history file.
1973       M-digits  (Escape)  Define numeric parameter, the digits are taken as a
1974                 parameter to the next command.  The commands  that  accept  a
1975                 parameter are ^F, ^B, erase, ^C, ^D, ^K, ^R, ^P, ^N, ^], M-.,
1976                 M-^], M-_, M-=, M-b, M-c, M-d, M-f, M-h, M-l, M-^H,  and  the
1977                 arrow keys and forward-delete key.
1978       M-letter  Soft-key  -  Your  alias list is searched for an alias by the
1979                 name _letter and if an alias of this  name  is  defined,  its
1980                 value  will  be inserted on the input queue.  The letter must
1981                 not be one of the above meta-functions.
1982       M-[letter Soft-key - Your alias list is searched for an  alias  by  the
1983                 name  __letter  and  if an alias of this name is defined, its
1984                 value will be inserted on the input queue.  This can be  used
1985                 to program function keys on many terminals.
1986       M-.       The  last  word  of  the  previous command is inserted on the
1987                 line.  If preceded by a numeric parameter, the value of  this
1988                 parameter  determines  which  word  to insert rather than the
1989                 last word.
1990       M-_       Same as M-..
1991       M-*       Attempt file name generation on the current word.  An  aster‐
1992                 isk is appended if the word doesn't match any file or contain
1993                 any special pattern characters.
1994       M-ESC     Command or file name completion as described above.
1995       ^I tab    Attempts command or file name completion as described  above.
1996                 If a partial completion occurs, repeating this will behave as
1997                 if M-= were entered.  If no match is found or  entered  after
1998                 space, a tab is inserted.
1999       M-=       If not preceded by a numeric parameter, it generates the list
2000                 of matching commands or file names as described above.   Oth‐
2001                 erwise,  the  word  under  the cursor is replaced by the item
2002                 corresponding to the value of the numeric parameter from  the
2003                 most  recently generated command or file list.  If the cursor
2004                 is not on a word, it is inserted instead.
2005       ^U        Multiply parameter of next command by 4.
2006       \         If the backslashctrl shell option is on (which is the default
2007                 setting),  this  escapes the next character.  Editing charac‐
2008                 ters, the user's erase,  kill  and  interrupt  (normally  ^C)
2009                 characters  may  be  entered in a command line or in a search
2010                 string if preceded by a \.  The \ removes  the  next  charac‐
2011                 ter's editing features (if any).  See also lnext which is not
2012                 subject to any shell option.
2013       M-^V      Display version of the shell.
2014       M-#       If the line does not begin with a #, a # is inserted  at  the
2015                 beginning  of  the line and after each new-line, and the line
2016                 is entered.  This causes a comment to be inserted in the his‐
2017                 tory file.  If the line begins with a #, the # is deleted and
2018                 one # after each new-line is also deleted.
2019
2020   Vi Editing Mode.
2021       There are two typing modes.  Initially, when you enter  a  command  you
2022       are in the input mode.  To edit, the user enters control mode by typing
2023       ESC (033) and moves the cursor to the point needing correction and then
2024       inserts  or  deletes  characters or words as needed.  Most control com‐
2025       mands accept an optional repeat count prior to the command.
2026
2027       The notation for control characters used below is ^ followed by a char‐
2028       acter.  For instance, ^H is entered by holding down the Control key and
2029       pressing H.  ^[ (Control+[) is equivalent to the ESC key.  The notation
2030       for escape sequences is ^[ followed by one or more characters.
2031
2032       The ^[[ (ESC [) multi-character commands below are DEC VT220 escape se‐
2033       quences generated by special keys on standard PC keyboards, such as the
2034       arrow  keys,  which  are  indicated in parentheses. When in input mode,
2035       these keys will switch you to control mode before performing the  asso‐
2036       ciated  action.  These sequences can use preceding repeat count parame‐
2037       ters, but only when the ^[ and the subsequent [ are  entered  into  the
2038       input buffer at the same time, such as when pressing one of those keys.
2039
2040        Input Edit Commands
2041              By default the editor is in input mode.
2042              erase     (User  defined  erase character as defined by the stty
2043                        command, usually ^H or #.)  Delete previous character.
2044              ^W        Delete the previous blank  separated  word.   On  some
2045                        systems  the  viraw option may be required for this to
2046                        work.
2047              eof       As the first character of the line causes the shell to
2048                        terminate  unless the ignoreeof option is set.  Other‐
2049                        wise this character is ignored.
2050              lnext     (User defined literal next character as defined by the
2051                        stty(1) or ^V if not defined.)  Removes the next char‐
2052                        acter's editing features (if any).   On  some  systems
2053                        the viraw option may be required for this to work.
2054              \         If  the backslashctrl shell option is on (which is the
2055                        default setting), this escapes the next erase or  kill
2056                        character.
2057              ^I tab    Attempts  command or file name completion as described
2058                        above and returns to input mode.  If a partial comple‐
2059                        tion  occurs,  repeating this will behave as if = were
2060                        entered from control mode.  If no match  is  found  or
2061                        entered after space, a tab is inserted.
2062        Motion Edit Commands
2063              These commands will move the cursor.
2064              [count]l  Cursor forward (right) one character.
2065              [count]^[[C
2066                        (Right arrow) Same as l.
2067              [count]w  Cursor forward one alphanumeric word.
2068              [count]W  Cursor  to the beginning of the next word that follows
2069                        a blank.
2070              [count]e  Cursor to end of word.
2071              [count]E  Cursor to end of the current blank delimited word.
2072              [count]h  Cursor backward (left) one character.
2073              [count]^[[D
2074                        (Left arrow) Same as h.
2075              [count]b  Cursor backward one word.
2076              [count]B  Cursor to preceding blank separated word.
2077              [count]|  Cursor to column count.
2078              [count]fc Find the next character c in the current line.
2079              [count]Fc Find the previous character c in the current line.
2080              [count]tc Equivalent to f followed by h.
2081              [count]Tc Equivalent to F followed by l.
2082              [count];  Repeats count times, the last  single  character  find
2083                        command, f, F, t, or T.
2084              [count],  Reverses  the last single character find command count
2085                        times.
2086              0         Cursor to start of line.
2087              ^[[H      (Home) Same as 0.
2088              ^         Cursor to first non-blank character in line.
2089              $         Cursor to end of line.
2090              ^[[F      (End) Same as $.
2091              ^[[Y      Same as $.
2092              %         Moves to balancing (, ), {, }, [, or ].  If cursor  is
2093                        not  on  one of the above characters, the remainder of
2094                        the line is searched for the first occurrence  of  one
2095                        of the above characters first.
2096        Search Edit Commands
2097              These commands access your command history.
2098              [count]k  Fetch  previous  command.   Each time k is entered the
2099                        previous command back in time is accessed.
2100              [count]-  Equivalent to k.
2101              [count]^[[A
2102                        (Up arrow) If cursor is at the end of the line  it  is
2103                        equivalent to / with string set to the contents of the
2104                        current line.  Otherwise, it is equivalent to k.
2105              [count]j  Fetch next command.  Each time j is entered  the  next
2106                        command forward in time is accessed.
2107              [count]+  Equivalent to j.
2108              [count]^[[B
2109                        (Down arrow) Equivalent to j.
2110              [count]G  The  command  number count is fetched.  The default is
2111                        the least recent history command.
2112              /string   Search backward through history for a previous command
2113                        containing string.  String is terminated by a `RETURN'
2114                        or `NEW LINE'.  If string is  preceded  by  a  ^,  the
2115                        matched  line  must  begin  with string.  If string is
2116                        null, the previous string will be used.
2117              ?string   Same as / except that search will be  in  the  forward
2118                        direction.
2119              n         Search  for  next  match of the last pattern to / or ?
2120                        commands.
2121              N         Search for next match of the last pattern to /  or  ?,
2122                        but in reverse direction.
2123        Text Modification Edit Commands
2124              These commands will modify the line.
2125              a         Enter  input  mode  and  enter  text after the current
2126                        character.
2127              A         Append text to the end of the line.  Equivalent to $a.
2128              [count]cmotion
2129              c[count]motion
2130                        Delete current character through  the  character  that
2131                        motion  would move the cursor to and enter input mode.
2132                        If motion is c, the entire line will  be  deleted  and
2133                        input mode entered.
2134              C         Delete  the  current character through the end of line
2135                        and enter input mode.  Equivalent to c$.
2136              S         Equivalent to cc.
2137              [count]s  Replace characters under the cursor in input mode.
2138              D         Delete the current character through the end of  line.
2139                        Equivalent to d$.
2140              [count]dmotion
2141              d[count]motion
2142                        Delete  current  character  through the character that
2143                        motion would move to.  If motion is  d  ,  the  entire
2144                        line will be deleted.
2145              i         Enter  input  mode  and insert text before the current
2146                        character.
2147              I         Insert text before the beginning of the line.  Equiva‐
2148                        lent to 0i.
2149              [count]P  Place  the  previous text modification before the cur‐
2150                        sor.
2151              [count]p  Place the previous text modification after the cursor.
2152              R         Enter input mode and replace characters on the  screen
2153                        with characters you type overlay fashion.
2154              [count]rc Replace the count character(s) starting at the current
2155                        cursor position with c, and advance the cursor.
2156              [count]x  Delete current character.
2157              [count]^[[3~
2158                        (Forward delete) Same as x.
2159              [count]X  Delete preceding character.
2160              [count].  Repeat the previous text modification command.
2161              [count]Invert the case of the count character(s) starting  at
2162                        the current cursor position and advance the cursor.
2163              [count]_  Causes  the  count  word of the previous command to be
2164                        appended and input mode entered.   The  last  word  is
2165                        used if count is omitted.
2166              *         Causes  an  *  to  be appended to the current word and
2167                        file name generation attempted.  If no match is found,
2168                        it rings the bell.  Otherwise, the word is replaced by
2169                        the matching pattern and input mode is entered.
2170              \         Command or file name completion as described above.
2171        Other Edit Commands
2172              Miscellaneous commands.
2173              [count]ymotion
2174              y[count]motion
2175                        Yank current character through character  that  motion
2176                        would move the cursor to and puts them into the delete
2177                        buffer.  The text and cursor are unchanged.
2178              yy        Yanks the entire line.
2179              Y         Yanks from current position to end of  line.   Equiva‐
2180                        lent to y$.
2181              u         Undo the last text modifying command.
2182              U         Undo  all the text modifying commands performed on the
2183                        line.
2184              [count]v  Returns the command hist  -e  ${VISUAL:-${EDITOR:-vi}}
2185                        count  in the input buffer.  If count is omitted, then
2186                        the current line is used.
2187              ^L        Line feed and print current line.  Has effect only  in
2188                        control mode.
2189              ^J        (New line)  Execute  the  current  line, regardless of
2190                        mode.
2191              ^M        (Return) Execute the current line, regardless of mode.
2192              #         If the first character of the command  is  a  #,  then
2193                        this  command deletes this # and each # that follows a
2194                        newline.  Otherwise, sends the line after inserting  a
2195                        #  in  front  of each line in the command.  Useful for
2196                        causing the current line to be inserted in the history
2197                        as  a  comment  and  uncommenting previously commented
2198                        commands in the history file.
2199              [count]=  If count is not specified, it generates  the  list  of
2200                        matching  commands  or  file names as described above.
2201                        Otherwise, the word under the cursor  is  replaced  by
2202                        the  count  item from the most recently generated com‐
2203                        mand or file list.  If the cursor is not on a word, it
2204                        is inserted instead.
2205              @letter   Your  alias  list is searched for an alias by the name
2206                        _letter and if an alias of this name is  defined,  its
2207                        value will be inserted on the input queue for process‐
2208                        ing.
2209              ^V        Display version of the shell.
2210
2211   Built-in Commands.
2212       The simple-commands listed below are built in to the shell and are exe‐
2213       cuted  in  the same process as the shell.  The effects of any added In‐
2214       put/Output redirections are local to the command, except for  the  exec
2215       and redirect commands.  Unless otherwise indicated, the output is writ‐
2216       ten on standard output (file descriptor 1) and the  exit  status,  when
2217       there  is  no  syntax  error,  is zero.  Except for :, true, false, and
2218       echo, all built-in commands accept -- to indicate end of  options,  and
2219       are self-documenting.
2220
2221       The  self-documenting  commands interpret the option --man as a request
2222       to display that command's own manual page, --help as a request to  dis‐
2223       play  the  OPTIONS section from their manual page, and -?  as a request
2224       to print a brief usage message.  All these are processed as error  mes‐
2225       sages, so they are written on standard error (file descriptor 2) and to
2226       pipe them into a pager such as more(1) you need to add a 2>&1 redirect‐
2227       ion before the |. The display of boldface text depends on whether stan‐
2228       dard error is on a terminal, so is disabled when using a pager. Export‐
2229       ing  the ERROR_OPTIONS environment variable with a value containing em‐
2230       phasis will force this on; a value containing noemphasis forces it off.
2231       The  test/[  command needs an additional -- argument to recognize self-
2232       documentation options, e.g. test --man --.  The exec and redirect  com‐
2233       mands,  as they make redirections permanent, should use self-documenta‐
2234       tion options in a subshell when  redirecting,  for  example:  (redirect
2235       --man)  2>&1.   There  are advanced output options as well; see getopts
2236       --man for more information.
2237
2238       Commands that are preceded by  a  †  symbol  below  are  special built-
2239       in commands and are treated specially in the following ways:
2240       1.     Variable assignment lists preceding the command remain in effect
2241              when the command completes.
2242       2.     I/O redirections are processed after variable assignments.
2243       3.     Errors cause a script that contains them to abort.
2244       4.     They are not valid function names.
2245       Commands that are preceded by a ‡  symbol  below  are  declaration com‐
2246       mands.   Any  following  words that are in the format of a variable as‐
2247       signment are expanded with the same rules  as  a  variable  assignment.
2248       This  means  that  tilde expansion is performed after the = sign, array
2249       assignments of the form varname=(assign_list) are supported, and  field
2250       splitting and file name generation are not performed.
2251
2252: [ arg ... ]
2253              The command only expands parameters.
2254
2255. name [ arg ... ]
2256              If  name  is  a function defined with the function name reserved
2257              word syntax, the function is executed in the current environment
2258              (as  if  it had been defined with the name() syntax).  Otherwise
2259              if name refers to a file, the file is read in its  entirety  and
2260              the commands are executed in the current shell environment.  The
2261              search path specified by PATH is used to find the directory con‐
2262              taining  the  file.  If any arguments arg are given, they become
2263              the positional parameters while processing the  .   command  and
2264              the original positional parameters are restored upon completion.
2265              Otherwise the positional parameters  are  unchanged.   The  exit
2266              status is the exit status of the last command executed.
2267
2268       [ expression ]
2269              The  [  command  is the same as test, with the exception that an
2270              additional closing ] argument is required. See test below.
2271
2272       alias [ -ptx ]  [ name[ =value  ] ] ...
2273              alias with no arguments prints the list of aliases in  the  form
2274              name=value  on  standard  output.  The -p option causes the word
2275              alias to be inserted before each one.  When one  or  more  argu‐
2276              ments  are  given, an alias is defined for each name whose value
2277              is given.  A trailing space in value causes the next word to  be
2278              checked  for  alias substitution.  With the -t option, each name
2279              is looked up as a command in $PATH and its path is added to  the
2280              hash  table  as  a  'tracked  alias'.  If no name is given, this
2281              prints the hash table. See hash.  Without  the  -t  option,  for
2282              each  name in the argument list for which no value is given, the
2283              name and value of the alias is printed.  The obsolete -x  option
2284              has  no effect.  The exit status is non-zero if a name is given,
2285              but no value, and no alias has been defined for the name.
2286
2287       autoload name ...
2288              Marks each name undefined so that the  FPATH  variable  will  be
2289              searched  to  find  the function definition when the function is
2290              referenced.  The same as typeset -fu.
2291
2292       bg [ job... ]
2293              This command is only on systems that support job control.   Puts
2294              each  specified job into the background.  The current job is put
2295              in the background if job is not specified.  See Jobs for  a  de‐
2296              scription of the format of job.
2297
2298break [ n ]
2299              Exit  from  the  enclosing for, while, until, or select loop, if
2300              any.  If n is specified, then break n levels.
2301
2302       builtin [ -ds ] [ -f file ] [ name ... ]
2303              If name is not specified, and no -f  option  is  specified,  the
2304              built-ins  are printed on standard output.  The -s option prints
2305              only the special built-ins.  Otherwise, each name represents the
2306              pathname  whose basename is the name of the built-in.  The entry
2307              point function name is determined by prepending b_ to the built-
2308              in  name.   A built-in specified by a pathname will only be exe‐
2309              cuted when that pathname would be found during the path  search.
2310              Built-ins found in libraries loaded via the .paths file will as‐
2311              sociate with the pathname of the directory containing the .paths
2312              file.
2313
2314              The  ISO  C/C++ prototype is b_mycommand(int argc, char *argv[],
2315              void *context) for the builtin command mycommand where  argv  is
2316              array  an of argc elements and context is an optional pointer to
2317              a Shell_t structure as described in <ast/shell.h>.
2318
2319              Special built-ins cannot be bound to a pathname or deleted.  The
2320              -d  option deletes each of the given built-ins.  On systems that
2321              support dynamic loading, the -f option names  a  shared  library
2322              containing  the  code  for built-ins.  The shared library prefix
2323              and/or suffix, which depend on the system, can be omitted.  Once
2324              a library is loaded, its symbols become available for subsequent
2325              invocations of builtin.  Multiple  libraries  can  be  specified
2326              with separate invocations of the builtin command.  Libraries are
2327              searched in the reverse order in which they are specified.  When
2328              a  library  is  loaded,  it  looks for a function in the library
2329              whose name is lib_init() and invokes this function with an argu‐
2330              ment of 0.
2331
2332       cd [ -LP ] [ arg ]
2333       cd [ -LP ] old new
2334              This  command  can be in either of two forms.  In the first form
2335              it changes the current directory to arg.  If arg is - the direc‐
2336              tory  is  changed to the previous directory.  The shell variable
2337              HOME is the default arg.  The variable PWD is set to the current
2338              directory.   The  shell  variable CDPATH defines the search path
2339              for the directory containing arg.  Alternative  directory  names
2340              are separated by a colon (:).  The default path is <null> (spec‐
2341              ifying the current directory).  Note that the current  directory
2342              is  specified  by a null path name, which can appear immediately
2343              after the equal sign or between the  colon  delimiters  anywhere
2344              else  in  the path list.  If arg begins with a / then the search
2345              path is not used.  Otherwise, each  directory  in  the  path  is
2346              searched for arg.
2347              The  second form of cd substitutes the string new for the string
2348              old in the current directory name, PWD, and tries to  change  to
2349              this new directory.
2350              By default, symbolic link names are treated literally when find‐
2351              ing the directory name.  This is equivalent to  the  -L  option.
2352              The  -P  option causes symbolic links to be resolved when deter‐
2353              mining the directory.  The last instance of -L or -P on the com‐
2354              mand line determines which method is used.
2355              The cd command may not be executed by rksh.
2356
2357       command [ -pvxV ] name [ arg ... ]
2358              With the -v option, command is equivalent to the built-in whence
2359              command described below.  The -V option causes  command  to  act
2360              like whence -v.
2361
2362              Without the -v or -V options, command executes name with the ar‐
2363              guments given  by  arg.   Functions  and  aliases  will  not  be
2364              searched  for  when  finding  name.  If name refers to a special
2365              built-in, as marked with in this manual, command disables  the
2366              special  properties described above for that mark, executing the
2367              command as a regular built-in.  (For example, using command  set
2368              -o  option-name  prevents  a script from terminating when an in‐
2369              valid option name is given.)
2370
2371              The -p option causes the operating system's  standard  utilities
2372              path  (as output by getconf PATH) to be searched rather than the
2373              one defined by the value of PATH.
2374
2375              The -x option runs name as an external command, bypassing built-
2376              ins.  If the arguments contain at least one word that expands to
2377              multiple arguments, such as "$@" or *.txt, then  the  -x  option
2378              also allows executing external commands with argument lists that
2379              are longer than the operating system allows. This  functionality
2380              is similar to xargs(1) but is easier to use. The shell does this
2381              by invoking the external command multiple times if  needed,  di‐
2382              viding  the expanded argument list over the invocations. Any ar‐
2383              guments that come before the first word that expands to multiple
2384              arguments,  as  well  as any that follow the last such word, are
2385              considered static arguments and are repeated  for  each  invoca‐
2386              tion.  This  allows  each invocation to use the same command op‐
2387              tions, as well as the same trailing  destination  arguments  for
2388              commands  like  cp(1)  or  mv(1).  When all invocations are com‐
2389              pleted, command -x exits with the status of the invocation  that
2390              had  the  highest  exit status.  (Note that command -x may still
2391              fail with an "argument list too long" error if a single argument
2392              exceeds  the  maximum  length of the argument list, or if a long
2393              arguments list contains no word that expands to  multiple  argu‐
2394              ments.)
2395
2396compound vname[=value] ...
2397              Causes  each vname to be a compound variable.  The same as type‐
2398              set -C.
2399
2400continue [ n ]
2401              Resume the next iteration of the enclosing for, while, until, or
2402              select loop.  If n is specified, then resume at the n-th enclos‐
2403              ing loop.
2404
2405       disown [ job... ]
2406              Causes the shell not to send a HUP signal to each given job,  or
2407              all  active  jobs  if  job is omitted, when a login shell termi‐
2408              nates.
2409
2410       echo [ arg ... ]
2411              When the first arg does not begin with a -, and none of the  ar‐
2412              guments contain a \, then echo prints each of its arguments sep‐
2413              arated by a space and terminated by a new-line.  Otherwise,  the
2414              behavior  of  echo  is  system dependent and print or printf de‐
2415              scribed below should be used.  See echo(1)  for  usage  and  de‐
2416              scription.
2417
2418enum [ -i  ] type[=(value ...) ]
2419              Creates a declaration command named type that is an integer type
2420              that allows one of the specified values  as  enumeration  names.
2421              If  =(value ...)  is omitted, then type must be an indexed array
2422              variable with at least two elements and  the  values  are  taken
2423              from  this  array  variable.   If -i is specified the values are
2424              case-insensitive.  Declaration commands are created  as  special
2425              builtins  that  cannot  be  removed or overridden by shell func‐
2426              tions.
2427
2428eval [ arg ... ]
2429              The arguments are read as input to the shell and  the  resulting
2430              command(s) executed.
2431
2432exec [ -c ] [ -a name ] [ arg ... ]
2433              If  arg is given, the command specified by the arguments is exe‐
2434              cuted in place of this shell without  creating  a  new  process.
2435              The -c option causes the environment to be cleared before apply‐
2436              ing variable assignments associated with  the  exec  invocation.
2437              The  -a  option causes name rather than the first arg, to become
2438              argv[0] for the new process.  If arg is not given and  only  I/O
2439              redirections  are given, then this command persistently modifies
2440              file descriptors as in redirect.
2441
2442exit [ n ]
2443              Causes the shell to exit with the exit status  specified  by  n.
2444              The  value will be the least significant 8 bits of the specified
2445              status.  If n is omitted, then the exit status is  that  of  the
2446              last command executed.  An end-of-file will also cause the shell
2447              to exit except for a shell which has the ignoreeof  option  (see
2448              set below) turned on.
2449
2450       †‡ export [ -p ] [ name[=value] ] ...
2451              If name is not given, the names and values of each variable with
2452              the export attribute are printed with the  values  quoted  in  a
2453              manner  that  allows them to be re-input.  The export command is
2454              the same as typeset -x except that if you use  export  within  a
2455              function,  no  local  variable is created.  The -p option causes
2456              the word export to be inserted before each one.  Otherwise,  the
2457              given  names  are marked for automatic export to the environment
2458              of subsequently-executed commands.
2459
2460       false  Does nothing, and exits 1. Used with until for infinite loops.
2461
2462       fc [ -e ename  ] [ -N num ] [ -nlr ] [ first [ last ] ]
2463       fc -s  [ old=new ] [ command ]
2464              The same as hist.
2465
2466       fg [ job... ]
2467              This command is only on systems that support job control.   Each
2468              job specified is brought to the foreground and waited for in the
2469              specified order.  Otherwise, the current job is brought into the
2470              foreground.  See Jobs for a description of the format of job.
2471
2472float vname[=value] ...
2473              Declares  each  vname  to  be a long floating point number.  The
2474              same as typeset -lE.
2475
2476       functions [ -Stux ] [ name ... ]
2477              Lists functions.  The same as typeset -f.
2478
2479       getconf [ name [ pathname ] ]
2480              Prints the current value of the configuration parameter given by
2481              name.   The  configuration  parameters  are  defined by the IEEE
2482              POSIX 1003.1 and IEEE POSIX 1003.2 standards.  (See  pathconf(2)
2483              and  sysconf(3).)  The pathname argument is required for parame‐
2484              ters whose value depends on the location in the file system.  If
2485              no  arguments  are given, getconf prints the names and values of
2486              the current configuration parameters.  The pathname  /  is  used
2487              for each of the parameters that requires pathname.
2488
2489       getopts [ -a name ] optstring vname [ arg ... ]
2490              Checks arg for legal options.  If arg is omitted, the positional
2491              parameters are used.  An option argument begins with a + or a -.
2492              An  option not beginning with + or - or the argument -- ends the
2493              options.  Options beginning with + are only recognized when opt‐
2494              string  begins  with  a  +.  optstring contains the letters that
2495              getopts recognizes.  If a letter is followed by a :, that option
2496              is  expected  to have an argument.  The options can be separated
2497              from the argument by blanks.  The option -?  causes  getopts  to
2498              generate a usage message on standard error.  The -a argument can
2499              be used to specify the name to use for the usage message,  which
2500              defaults to $0.
2501              getopts  places  the next option letter it finds inside variable
2502              vname each time it  is  invoked.   The  option  letter  will  be
2503              prepended  with  a + when arg begins with a +.  The index of the
2504              next arg is stored in OPTIND.  The option argument, if any, gets
2505              stored in OPTARG.
2506              A  leading  : in optstring causes getopts to store the letter of
2507              an invalid option in OPTARG, and to set vname to ?  for  an  un‐
2508              known  option  and to : when a required option argument is miss‐
2509              ing.  Otherwise, getopts prints an error message.  The exit sta‐
2510              tus is non-zero when there are no more options.
2511              There is no way to specify any of the options :, +, -, ?, [, and
2512              ].  The option # can only be specified as the first option.
2513
2514       hash [ -r ] [ utility ]
2515              hash displays or modifies the hash table with the  locations  of
2516              recently used programs. If given no arguments, it lists all com‐
2517              mand/path associations (a.k.a. 'tracked aliases')  in  the  hash
2518              table.  Otherwise,  hash performs a PATH search for each utility
2519              supplied and adds the result to the hash table.  The  -r  option
2520              empties  the  hash table. This can also be achieved by resetting
2521              PATH.
2522
2523       hist [ -e ename  ] [ -N num ] [ -nlr ] [ first [ last ] ]
2524       hist -s [ old=new ] [ command ]
2525              In the first form, a range of commands from first to last is se‐
2526              lected  from  the  last HISTSIZE commands that were typed at the
2527              terminal.  The arguments first and last may be  specified  as  a
2528              number  or as a string.  A string is used to locate the most re‐
2529              cent command starting with the given string.  A negative  number
2530              is  used  as an offset to the current command number.  If the -l
2531              option is selected, the commands are listed on standard  output.
2532              Otherwise,  the  editor  program ename is invoked on a file con‐
2533              taining these keyboard commands.  If ename is not supplied, then
2534              the  value of the variable HISTEDIT is used.  If HISTEDIT is not
2535              set, then FCEDIT (default /bin/ed) is used as the editor.   When
2536              editing  is  complete,  the edited command(s) is executed if the
2537              changes have been saved.  If last is not specified, then it will
2538              be  set to first.  If first is not specified, the default is the
2539              previous command for editing and -16 for listing.  The option -r
2540              reverses  the order of the commands and the option -n suppresses
2541              command numbers when listing.  In the second  form,  command  is
2542              interpreted  as  first  described above and defaults to the last
2543              command executed.  The resulting command is executed  after  the
2544              optional  substitution  old=new  is  performed.   The  option -N
2545              causes hist to start num commands back.
2546
2547integer vname[=value] ...
2548              Declares each vname to be a long integer number.   The  same  as
2549              typeset -li.
2550
2551       jobs [ -lnp ] [ job ... ]
2552              Lists  information  about  each given job; or all active jobs if
2553              job is omitted.  The -l option lists process ids in addition  to
2554              the  normal  information.  The -n option only displays jobs that
2555              have stopped or exited  since  last  notified.   The  -p  option
2556              causes  only the process group to be listed.  See Jobs for a de‐
2557              scription of the format of job.
2558
2559       kill [ -s signame ] job ...
2560       kill [ -n signum ] job ...
2561       kill -Ll [ sig ... ]
2562              Sends either the TERM (terminate) signal or the specified signal
2563              to the specified jobs or processes.  Signals are either given by
2564              number with the -n option or by name  with  the  -s  option  (as
2565              given in <signal.h>, stripped of the prefix ``SIG'' with the ex‐
2566              ception that SIGCLD is named CHLD).  For backward compatibility,
2567              the n and s can be omitted and the number or name placed immedi‐
2568              ately after the -.  If the signal being sent is TERM (terminate)
2569              or  HUP  (hangup),  then  the job or process will be sent a CONT
2570              (continue) signal if it is stopped.  The argument job can be the
2571              process  id  of a process that is not a member of one of the ac‐
2572              tive jobs.  See Jobs for a description of the format of job.  In
2573              the  third  form,  kill -l, or kill -L, if sig is not specified,
2574              the signal names are listed.  The -l option list only the signal
2575              names.  -L options lists each signal name and corresponding num‐
2576              ber.  Otherwise, for each sig that is a name, the  corresponding
2577              signal  number  is  listed.   For each sig that is a number, the
2578              signal name corresponding to the least significant 8 bits of sig
2579              is listed.
2580
2581       let arg ...
2582              Each  arg  is  a separate arithmetic expression to be evaluated.
2583              let only recognizes octal constants starting with 0 when the set
2584              option  letoctal  is on.  See Arithmetic Evaluation above, for a
2585              description of arithmetic expression evaluation.
2586              The exit status is 0 if the value of the last expression is non-
2587              zero, and 1 otherwise.
2588
2589nameref vname[=refname] ...
2590              Declares  each  vname to be a variable name reference.  The same
2591              as typeset -n.
2592
2593       print [ -CRenprsv ] [ -u unit ] [ -f format ] [ arg ... ]
2594              With no options or with option - or --, each arg is  printed  on
2595              standard  output.   The  -f  option  causes  the arguments to be
2596              printed as described by printf.  In this case, any e,  n,  r,  R
2597              options  are  ignored.   Otherwise, unless the -C, -R, -r, or -v
2598              are specified, the following escape conventions will be applied:
2599              \a     The alert character (ascii 07).
2600              \b     The backspace character (ascii 010).
2601              \c     Causes print to end without processing more arguments and
2602                     not adding a new-line.
2603              \f     The formfeed character (ascii 014).
2604              \n     The newline character (ascii 012).
2605              \r     The carriage return character (ascii 015).
2606              \t     The tab character (ascii 011).
2607              \v     The vertical tab character (ascii 013).
2608              \E     The escape character (ascii 033).
2609              \\     The backslash character \.
2610              \0x    The  character  defined  by  the  1,  2, or 3-digit octal
2611                     string given by x.
2612
2613              The -R option will print all subsequent  arguments  and  options
2614              other than -n.  The -e causes the above escape conventions to be
2615              applied.  This is the default behavior.  It reverses the  effect
2616              of  an  earlier  -r.   The  -p option causes the arguments to be
2617              written onto the pipe of the process spawned with |& instead  of
2618              standard  output.   The  -v option treats each arg as a variable
2619              name and writes the value in the printf %B format.  The  -C  op‐
2620              tion  treats each arg as a variable name and writes the value in
2621              the printf %#B format.  The -s option causes the arguments to be
2622              written  onto  the history file instead of standard output.  The
2623              -u option can be used to specify a  one  digit  file  descriptor
2624              unit  number  unit  on which the output will be placed.  The de‐
2625              fault is 1.  If the option -n is used, no new-line is  added  to
2626              the output.
2627
2628       printf format [ arg ... ]
2629              The  arguments  arg are printed on standard output in accordance
2630              with the ANSI-C formatting  rules  associated  with  the  format
2631              string format.  If the number of arguments exceeds the number of
2632              format specifications, the format string is reused to format re‐
2633              maining arguments.  The following extensions can also be used:
2634              %b     A %b format can be used instead of %s to cause escape se‐
2635                     quences in the corresponding arg to be  expanded  as  de‐
2636                     scribed in print.
2637              %B     A %B option causes each of the arguments to be treated as
2638                     variable names and the binary value of variable  will  be
2639                     printed.  The alternate flag # causes a compound variable
2640                     to be output on a single line.  This is most  useful  for
2641                     compound variables and variables whose attribute is -b.
2642              %H     A %H format can be used instead of %s to cause characters
2643                     in arg that are special in HTML and XML to be  output  as
2644                     their entity name.  The alternate flag # formats the out‐
2645                     put for use as a URI.
2646              %p     A %p format will convert the given number to hexadecimal.
2647              %P     A %P format can be used instead of %s to cause arg to  be
2648                     interpreted  as  an  extended  regular  expression and be
2649                     printed as a shell pattern.
2650              %q     A %q format can be used instead of %s to  cause  the  re‐
2651                     sulting string to be quoted in a manner than can be rein‐
2652                     put to the shell.  When q is preceded by the  alternative
2653                     format specifier, #, the string is quoted in manner suit‐
2654                     able as a field in a .csv format file.
2655              %(date-format)T
2656                     A %(date-format)T format can be used to treat an argument
2657                     as a date/time string and to format the date/time accord‐
2658                     ing to the date-format.
2659              %Q     A %Q format will convert the given number of  seconds  to
2660                     readable time.
2661              %R     A  %R format can be used instead of %s to cause arg to be
2662                     interpreted as a shell pattern and to be  printed  as  an
2663                     extended regular expression.
2664              %Z     A %Z format will output a byte whose value is 0.
2665              %d     The precision field of the %d format can be followed by a
2666                     .  and the output base.  In this case, the # flag charac‐
2667                     ter causes base# to be prepended.
2668              #      The  # flag, when used with the %d format without an out‐
2669                     put base, displays the output in powers of 1000 indicated
2670                     by  one  of the following suffixes: k M G T P E, and when
2671                     used with the %i format displays the output in powers  of
2672                     1024 indicated by one of the following suffixes: Ki Mi Gi
2673                     Ti Pi Ei.
2674              =      The = flag centers the output within the specified  field
2675                     width.
2676              L      The  L  flag, when used with the %c or %s formats, treats
2677                     precision as character width instead of byte count.
2678              ,      The , flag, when used with the %d or  %f  formats,  sepa‐
2679                     rates  groups of digits with the grouping delimiter (, on
2680                     groups of 3 in the C locale).
2681
2682       pwd [ -LP ]
2683              Outputs the value of the current working directory.  The -L  op‐
2684              tion  is  the default; it prints the logical name of the current
2685              directory.  If the -P option is given, all  symbolic  links  are
2686              resolved  from  the  name.  The last instance of -L or -P on the
2687              command line determines which method is used.
2688
2689       read [ -ACSprsv ] [ -d delim ] [ -n n ] [ [ -N n ] [ -t timeout ] [  -u
2690       unit ] [ vname?prompt ] [ vname ... ]
2691              The  shell  input  mechanism.  One line is read and is broken up
2692              into fields using the characters in IFS as separators.  The  es‐
2693              cape character, \, is used to remove any special meaning for the
2694              next character and for line continuation.  The -d option  causes
2695              the read to continue to the first character of delim rather than
2696              new-line.  The -n option causes at most n bytes to read rather a
2697              full  line  but  will  return when reading from a slow device as
2698              soon as any characters have been read.  The -N option causes ex‐
2699              actly n to be read unless an end-of-file has been encountered or
2700              the read times out because of the -t option.  In raw  mode,  -r,
2701              the  \  character  is not treated specially.  The first field is
2702              assigned to the first vname, the  second  field  to  the  second
2703              vname,  etc.,  with  leftover fields assigned to the last vname.
2704              When vname has the binary attribute and -n or -N  is  specified,
2705              the  bytes  that are read are stored directly into the variable.
2706              If the -v is specified, then the value of the first  vname  will
2707              be  used as a default value when reading from a terminal device.
2708              The -A option causes the variable vname to  be  unset  and  each
2709              field  that  is  read to be stored in successive elements of the
2710              indexed array vname.  The -C option causes the variable vname to
2711              be  read  as  a  compound variable.  Blanks will be ignored when
2712              finding the beginning open parenthesis.  The  -S  option  causes
2713              the  line  to  be treated like a record in a .csv format file so
2714              that double quotes can be used to allow the delimiter  character
2715              and the new-line character to appear within a field.  The -p op‐
2716              tion causes the input line to be taken from the input pipe of  a
2717              process  spawned  by  the  shell  using |&.  If the -s option is
2718              present, the input will be saved as a  command  in  the  history
2719              file.  The option -u can be used to specify a one digit file de‐
2720              scriptor unit unit to read from.  The  file  descriptor  can  be
2721              opened  with  the  exec  special  built-in command.  The default
2722              value of unit n is 0.  The option -t is used to specify a  time‐
2723              out  in  seconds when reading from a terminal or pipe.  If vname
2724              is omitted, then REPLY is used as the default vname.  An end-of-
2725              file  with the -p option causes cleanup for this process so that
2726              another can be spawned.  If the first argument contains a ?, the
2727              remainder  of  this  word  is used as a prompt on standard error
2728              when the shell is interactive.  The exit status is 0  unless  an
2729              end-of-file is encountered or read has timed out.
2730
2731       †‡ readonly [ -p ] [ vname[=value] ] ...
2732              If  vname  is  not  given, the names and values of each variable
2733              with the readonly attribute is printed with the values quoted in
2734              a  manner  that  allows  them  to be re-inputted.  The -p option
2735              causes the word readonly to be inserted before each one.  Other‐
2736              wise,  the given vnames are marked readonly and these names can‐
2737              not be changed by subsequent assignment.   Unlike  typeset -r  ,
2738              readonly  does  not  create a function-local scope and the given
2739              vnames are marked globally read-only by default.  When  defining
2740              a  type,  if the value of a readonly sub-variable is not defined
2741              the value is required when creating each instance.
2742
2743       redirect
2744              This command only accepts  input/output  redirections.   It  can
2745              open  and close files and modify file descriptors from 0 to 9 as
2746              specified by the input/output  redirection  list  (see  the  In‐
2747              put/Output  section  above), with the difference that the effect
2748              persists past the execution of the redirect command.   When  in‐
2749              voking  another  program,  file  descriptors greater than 2 that
2750              were opened with this mechanism are only passed on if  they  are
2751              explicitly  redirected  to  themselves as part of the invocation
2752              (e.g. 4>&4) or if the posix option is set.
2753
2754return [ n ]
2755              Causes a shell function or .  script to return to  the  invoking
2756              script  with  the exit status specified by n.  The value will be
2757              the least significant 8 bits of the specified status.  If  n  is
2758              omitted, then the return status is that of the last command exe‐
2759              cuted.  If return is invoked while not in  a  function  or  a  .
2760              script, then it behaves the same as exit.
2761
2762set  [  ±BCGHabefhkmnprstuvx ] [ ±o [ option ] ] ... [ ±A vname ]  [
2763       arg ... ]
2764              The options for this command have meaning as follows:
2765              -A      Array assignment.  Unset the variable vname  and  assign
2766                      values  sequentially  from the arg list.  If +A is used,
2767                      the variable vname is not unset first.
2768              -B      Enable brace group expansion. On by default,  except  if
2769                      ksh is invoked as sh or rsh.
2770              -C      Prevents  redirection  > from truncating existing files.
2771                      Files that are created are opened with the O_EXCL  mode.
2772                      Requires >| to truncate a file when turned on.
2773              -G      Enables  recursive  file name generation.  This adds the
2774                      double-star pattern ** to the file generation  mechanism
2775                      (see File Name Generation above).  By itself, it matches
2776                      the recursive contents of the current  directory,  which
2777                      is  to say, all files and directories in the current di‐
2778                      rectory and in all its  subdirectories,  sub-subdirecto‐
2779                      ries,  and  so on.  If the pathname pattern ends in **/,
2780                      only directories and subdirectories are matched, includ‐
2781                      ing  symbolic  links  that point to directories.  A pre‐
2782                      fixed directory name is not included in the results  un‐
2783                      less  that  directory was itself found by a pattern. For
2784                      example, dir/** matches the recursive  contents  of  dir
2785                      but  not  dir  itself, whereas di[r]/** matches both dir
2786                      itself and the  recursive  contents  of  dir.   Symbolic
2787                      links  to  non-directories  are  not followed.  Symbolic
2788                      links to directories are followed if they are  specified
2789                      literally  or  match  a  pattern as described under File
2790                      Name Generation, but not if they result from  a  double-
2791                      star pattern.
2792              -H      Enable !-style history expansion similar to csh(1).
2793              -a      All  subsequent variables that are defined are automati‐
2794                      cally exported.
2795              -b      Prints job completion messages as soon as  a  background
2796                      job  changes  state  rather  than  waiting  for the next
2797                      prompt.
2798              -e      Unless contained in a || or && command, or  the  command
2799                      following  an  if while or until command or in the pipe‐
2800                      line following !, if a command has a non-zero exit  sta‐
2801                      tus,  execute the ERR trap, if set, and exit.  This mode
2802                      is disabled while reading profiles.
2803              -f      Disables file name generation.
2804              -h      Each command becomes a tracked alias when first  encoun‐
2805                      tered.
2806              -k      (Obsolete). All variable assignment arguments are placed
2807                      in the environment for a command, not  just  those  that
2808                      precede the command name.
2809              -m      Background jobs will run in a separate process group and
2810                      a line will print upon completion.  The exit  status  of
2811                      background jobs is reported in a completion message.  On
2812                      systems with job control, this option is turned on auto‐
2813                      matically for interactive shells.
2814              -n      Read  commands  and check them for syntax errors, but do
2815                      not execute them.  Ignored for interactive shells.
2816              -o      The following argument can be one of the  following  op‐
2817                      tion names:
2818                      allexport
2819                              Same as -a.
2820                      backslashctrl
2821                              The  backslash character \ escapes the next con‐
2822                              trol character in the emacs built-in editor  and
2823                              the  next  erase  or  kill  character  in the vi
2824                              built-in editor.  On by default.
2825                      bgnice  All background jobs are run at a lower priority.
2826                              This is the default mode.
2827                      braceexpand
2828                              Same as -B.
2829                      emacs   Puts  you  in  an emacs style in-line editor for
2830                              command entry.
2831                      errexit Same as -e.
2832                      globcasedetect
2833                              When this option is  turned  on,  globbing  (see
2834                              File  Name Generation above) and file name list‐
2835                              ing and completion (see In-line Editing  Options
2836                              above)  automatically become case-insensitive on
2837                              file systems where the difference between upper-
2838                              and lowercase is ignored for file names. This is
2839                              transparently determined for each directory,  so
2840                              a  path pattern that spans multiple file systems
2841                              can be part case-sensitive and part  case-insen‐
2842                              sitive.  In more precise terms, each slash-sepa‐
2843                              rated path name component pattern p  is  treated
2844                              as  ~(i:p)  if  its parent directory exists on a
2845                              case-insensitive file system.   This  option  is
2846                              only  present  on operating systems that support
2847                              case-insensitive file systems.
2848                      globstar
2849                              Same as -G.
2850                      gmacs   Puts you in a gmacs  style  in-line  editor  for
2851                              command entry.
2852                      histexpand
2853                              Same as -H.
2854                      ignoreeof
2855                              The  shell  will  not  exit on end-of-file.  The
2856                              command exit must be used.
2857                      keyword Same as -k.
2858                      letoctal
2859                              The let command allows octal constants  starting
2860                              with  0.   On by default if ksh is invoked as sh
2861                              or rsh.
2862                      markdirs
2863                              All directory names  resulting  from  file  name
2864                              generation have a trailing / appended.
2865                      monitor Same as -m.
2866                      multiline
2867                              The  built-in editors will use multiple lines on
2868                              the screen for lines that are  longer  than  the
2869                              width  of the screen.  This may not work for all
2870                              terminals.
2871                      noclobber
2872                              Same as -C.
2873                      noexec  Same as -n.
2874                      noglob  Same as -f.
2875                      nolog   Obsolete; has no effect.
2876                      notify  Same as -b.
2877                      nounset Same as -u.
2878                      pipefail
2879                              A pipeline will not complete  until  all  compo‐
2880                              nents  of  the  pipeline have completed, and the
2881                              return value will be the value of the last  non-
2882                              zero  command  to fail or zero if no command has
2883                              failed.
2884                      posix   Enables the POSIX standard mode for maximum com‐
2885                              patibility  with  other compliant shells. At the
2886                              moment that the posix option is  turned  on,  it
2887                              also turns on letoctal and turns off -B/braceex‐
2888                              pand; the reverse is done when posix  is  turned
2889                              back off. (These options can still be controlled
2890                              independently  in  between.)  Furthermore,   the
2891                              posix option is automatically turned on upon in‐
2892                              vocation if ksh is invoked as sh or rsh. In that
2893                              case,  or if the option is turned on by specify‐
2894                              ing -o posix on the invocation command line, the
2895                              invoked  shell  will  not set the preset aliases
2896                              even if interactive, and will  not  import  type
2897                              attributes  for  variables  (such  as integer or
2898                              readonly) from the environment.
2899                              In addition, while on, the posix option
2900                              •  disables exporting variable  type  attributes
2901                                 to the environment for other ksh processes to
2902                                 import;
2903                              •  causes file descriptors > 2 to be  left  open
2904                                 when invoking another program;
2905                              •  disables the &> redirection shorthand;
2906                              •  makes  the <> redirection operator default to
2907                                 redirecting standard input  if  no  file  de‐
2908                                 scriptor number precedes it; and
2909                              •  disables  a  hack that makes test -t ([ -t ])
2910                                 equivalent to test -t 1 ([ -t 1 ]).
2911                      privileged
2912                              Same as -p.
2913                      showme  When enabled, simple commands or pipelines  pre‐
2914                              ceded by a semicolon (;) will be displayed as if
2915                              the xtrace option were enabled but will  not  be
2916                              executed.   Otherwise, the leading ; will be ig‐
2917                              nored.
2918                      trackall
2919                              Same as -h.
2920                      verbose Same as -v.
2921                      vi      Puts you in insert mode of a  vi  style  in-line
2922                              editor  until  you hit the escape character 033.
2923                              This puts you in control mode.  A  return  sends
2924                              the line.
2925                      viraw   Each character is processed as it is typed in vi
2926                              mode.  The shell may have been compiled to force
2927                              this option on at all times.  Otherwise, canoni‐
2928                              cal processing (line-by-line input) is initially
2929                              enabled  and  the  command  line  will be echoed
2930                              again if the speed is 1200 baud or  greater  and
2931                              it  contains any control characters or less than
2932                              one second has  elapsed  since  the  prompt  was
2933                              printed.  The ESC character terminates canonical
2934                              processing for the remainder of the command  and
2935                              the  user can then modify the command line. This
2936                              scheme has the advantages of canonical  process‐
2937                              ing  with the type-ahead echoing of raw mode. If
2938                              the viraw option is set, the terminal  will  al‐
2939                              ways  have  canonical processing disabled.  This
2940                              mode is implicit for systems that do not support
2941                              two alternate end of line delimiters, and may be
2942                              helpful for certain terminals.
2943                      xtrace  Same as -x.
2944                      If no option name is supplied, then the  current  option
2945                      settings are printed.
2946              -p      Disables  processing of the $HOME/.profile file and uses
2947                      the file /etc/suid_profile  instead  of  the  ENV  file.
2948                      This  mode is on whenever the effective uid (gid) is not
2949                      equal to the real uid (gid).  Turning  this  off  causes
2950                      the  effective uid and gid to be set to the real uid and
2951                      gid.
2952              -r      Enables the restricted shell.  This option cannot be un‐
2953                      set once set.
2954              -s      Sort the positional parameters lexicographically.
2955              -t      (Obsolete).   Exit  after reading and executing one com‐
2956                      mand.
2957              -u      Treat unset parameters as an  error  when  substituting.
2958                      $@ and $* are exempt.
2959              -v      Print shell input lines as they are read.
2960              -x      Print commands and their arguments as they are executed.
2961              --      Do  not  change any of the options; useful in setting $1
2962                      to a value beginning with -.   If  no  arguments  follow
2963                      this option then the positional parameters are unset.
2964
2965              As an obsolete feature, if the first arg is - then the -x and -v
2966              options are turned off and the next arg is treated as the  first
2967              argument.   Using  +  rather  than  - causes these options to be
2968              turned off.  These options can also be used upon  invocation  of
2969              the  shell.  The current set of options may be found in $-.  Un‐
2970              less -A is specified, the remaining arguments are positional pa‐
2971              rameters  and are assigned, in order, to $1 $2 ....  If no argu‐
2972              ments are given, then the names and values of all variables  are
2973              printed on the standard output.
2974
2975shift [ n ]
2976              The  positional  parameters  from $n+1 ...  are renamed $1 ... ,
2977              default n is 1.  The parameter n can be any  arithmetic  expres‐
2978              sion  that evaluates to a non-negative number less than or equal
2979              to $#.
2980
2981       sleep [ -s ] duration
2982              Suspends execution for the number of decimal  seconds  or  frac‐
2983              tions  of  a second given by duration.  duration can be an inte‐
2984              ger, floating point value or ISO 8601  duration  specifying  the
2985              length of time to sleep.  The option -s causes the sleep builtin
2986              to terminate when it receives any signal.  If  duration  is  not
2987              specified  in  conjunction with -s, sleep will wait for a signal
2988              indefinitely.
2989
2990       source name [ arg ... ]
2991              Same as ., except it is not treated as a special  built-in  com‐
2992              mand.
2993
2994       stop job ...
2995              Sends  a  SIGSTOP  signal  to one or more processes specified by
2996              job, suspending them until they receive SIGCONT.   The  same  as
2997              kill -s STOP.
2998
2999       suspend
3000              Sends a SIGSTOP signal to the main shell process, suspending the
3001              script or child shell session until it receives SIGCONT (for in‐
3002              stance,  when  typing  fg  in  the  parent shell). Equivalent to
3003              kill -s STOP "$$", except that it accepts no  operands  and  re‐
3004              fuses to suspend a login shell.
3005
3006       test expression
3007              The  test and [ commands execute conditional expressions similar
3008              to those specified for the [[ compound command under Conditional
3009              Expressions  above,  but with several important differences. The
3010              =, == and != operators test for string (in)equality without pat‐
3011              tern  matching;  the == variant is nonstandard and should not be
3012              used. The =∼, <, >, && and || operators are not available.  Most
3013              importantly,  as  test  and [ are simple regular commands, field
3014              splitting and file name generation are performed  on  all  their
3015              arguments  and all aspects of regular shell grammar (such as re‐
3016              direction) remain active. This is usually harmful, so care  must
3017              be  taken to quote arguments and expansions to avoid this. There
3018              are also certain inherent grammatical ambiguities in the expres‐
3019              sions. To avoid the many pitfalls arising from these issues, the
3020              [[ compound command should be used instead. The primary  purpose
3021              of  the  test  and [ commands is compatibility with other shells
3022              that lack [[.
3023
3024              The test/[ command does not parse options except  if  there  are
3025              two  arguments  and the second is --. To access the inline docu‐
3026              mentation with an option such as --man,  you  need  one  of  the
3027              forms test --man -- or [ --man -- ].
3028
3029       times  Displays  the  accumulated  user  and system CPU times, one line
3030              with the times used by the shell and another with those used  by
3031              all of the shell's child processes. No options are supported.
3032
3033trap [ -p ] [ action ] [ sig ] ...
3034              The  -p  option causes the trap action associated with each trap
3035              as specified by the arguments to  be  printed  with  appropriate
3036              quoting.   Otherwise,  action will be processed as if it were an
3037              argument to eval when the shell receives  signal(s)  sig.   Each
3038              sig can be given as a number or as the name of the signal.  Trap
3039              commands are executed in order of signal number.  Any attempt to
3040              set  a trap on a signal that was ignored on entry to the current
3041              shell is ineffective.  If action is omitted and the first sig is
3042              a  number,  or if action is -, then the trap(s) for each sig are
3043              reset to their original values.  If action is  the  null  string
3044              then  this signal is ignored by the shell and by the commands it
3045              invokes.  If sig is ERR then action will be executed whenever  a
3046              command has a non-zero exit status.  If sig is DEBUG then action
3047              will be executed before each command.  The variable  .sh.command
3048              will  contain  the shell-quoted arguments of the current command
3049              line when action is running.  If the exit status of the trap  is
3050              2  the  command will not be executed.  If the exit status of the
3051              trap is 255 and inside a function or a dot script, the  function
3052              or  dot  script  will  return.  If sig is 0 or EXIT and the trap
3053              statement is executed inside the body of a function defined with
3054              the  function  name  syntax, then the command action is executed
3055              after the function completes.  If sig is 0 or EXIT  for  a  trap
3056              set  outside any function then the command action is executed on
3057              exit from the shell.  If sig is KEYBD, then action will be  exe‐
3058              cuted  whenever a key is read while in emacs, gmacs, or vi mode.
3059              The trap command with no arguments prints a list of commands as‐
3060              sociated with each signal number.
3061
3062       An  exit  or  return without an argument in a trap action will preserve
3063       the exit status of the command that invoked the trap.
3064
3065       true   Does nothing, and exits 0. Used with while for infinite loops.
3066
3067       type [ -afpq ] name ...
3068              The same as whence -v.
3069
3070       †‡ typeset [ ±ACHSbflmnprstux ] [ ±EFLRXZi[n] ]   [ +-M  [ mapname ]  ]
3071       [ -T  [ tname=(assign_list) ] ] [ -h str ] [ -a [type] ] [ vname[=value
3072       ]  ] ...
3073              Sets attributes and values for shell  variables  and  functions.
3074              When  invoked  inside  a function defined with the function name
3075              syntax, a new instance of the variable vname is created, and the
3076              variable's  value  and  type are restored when the function com‐
3077              pletes.  The following list of attributes may be specified:
3078              -A     Declares vname to be an  associative  array.   Subscripts
3079                     are strings rather than arithmetic expressions.
3080              -C     Causes  each  vname  to  be a compound variable. If value
3081                     names a compound variable, it is copied into vname.  Oth‐
3082                     erwise, the empty compound value is assigned to vname.
3083              -a     Declares vname to be an indexed array.  If type is speci‐
3084                     fied, it must be the name of an enumeration type  created
3085                     with the enum command and it allows enumeration constants
3086                     to be used as subscripts.
3087              -E     Declares vname to be a double  precision  floating  point
3088                     number.   If n is non-zero, it defines the number of sig‐
3089                     nificant figures that  are  used  when  expanding  vname.
3090                     Otherwise, ten significant figures will be used.
3091              -F     Declares  vname  to  be a double precision floating point
3092                     number.  If n is  non-zero,  it  defines  the  number  of
3093                     places after the decimal point that are used when expand‐
3094                     ing vname.  Otherwise ten places after the decimal  point
3095                     will be used.
3096              -H     This  option  provides  UNIX to host-name file mapping on
3097                     non-UNIX machines.
3098              -L     Left justify and remove leading blanks from value.  If  n
3099                     is non-zero, it defines the width of the field, otherwise
3100                     it is determined by the width of the value of  first  as‐
3101                     signment.  When the variable is assigned to, it is filled
3102                     on the right with blanks or truncated, if  necessary,  to
3103                     fit into the field.  The -R option is turned off.
3104              -M     Use  the character mapping mapping defined by wctrans(3).
3105                     such as tolower and toupper when  assigning  a  value  to
3106                     each  of  the specified operands.  When mapping is speci‐
3107                     fied and there are not operands, all variables  that  use
3108                     this  mapping  are written to standard output.  When map‐
3109                     ping is omitted and there are  no  operands,  all  mapped
3110                     variables are written to standard output.
3111              -R     Right justify and fill with leading blanks.  If n is non-
3112                     zero, it defines the width of the field, otherwise it  is
3113                     determined by the width of the value of first assignment.
3114                     The field is left filled with blanks  or  truncated  from
3115                     the  end if the variable is reassigned.  The -L option is
3116                     turned off.
3117              -S     When used within the assign_list of a type definition, it
3118                     causes the specified sub-variable to be shared by all in‐
3119                     stances of the type.  When used inside a function defined
3120                     with  the function reserved word, the specified variables
3121                     will have function static scope.  Otherwise, the variable
3122                     is unset prior to processing the assignment list.
3123              -T     If  followed  by  tname, it creates a type named by tname
3124                     using the compound assignment assign_list to tname.  Oth‐
3125                     erwise,  it  writes  all the type definitions to standard
3126                     output.
3127              -X     Declares vname to be a double  precision  floating  point
3128                     number  and expands using the %a format of ISO-C99.  If n
3129                     is non-zero, it defines the number of  hex  digits  after
3130                     the  radix  point that is used when expanding vname.  The
3131                     default is 10.
3132              -Z     Right justify and fill with leading zeros  if  the  first
3133                     non-blank  character is a digit and the -L option has not
3134                     been set.  Remove leading zeros if the -L option is  also
3135                     set.   If  n  is  non-zero,  it  defines the width of the
3136                     field, otherwise it is determined by  the  width  of  the
3137                     value of first assignment.
3138              -f     The  names  refer  to function names rather than variable
3139                     names.  No assignments can be made  and  the  only  other
3140                     valid  options are -S, -t, -u and -x.  The -S can be used
3141                     with discipline functions defined in a type  to  indicate
3142                     that  the function is static.  For a static function, the
3143                     same method will be used by all instances of that type no
3144                     matter which instance references it.  In addition, it can
3145                     only use value of variables from the original type  defi‐
3146                     nition.   These  discipline functions cannot be redefined
3147                     in any type instance.  The -t option turns  on  execution
3148                     tracing  for  this  function.   The -u option causes this
3149                     function to be marked undefined.  The FPATH variable will
3150                     be  searched  to  find  the  function definition when the
3151                     function is referenced.  If no options other than  -f  is
3152                     specified, then the function definition will be displayed
3153                     on standard output.  If +f is specified, then a line con‐
3154                     taining  the  function  name  followed by a shell comment
3155                     containing the line number and  path  name  of  the  file
3156                     where  this  function  was defined, if any, is displayed.
3157                     The exit status can be  used  to  determine  whether  the
3158                     function is defined so that typeset -f .sh.math.name will
3159                     return 0 when math function name is defined and  non-zero
3160                     otherwise.
3161              -b     The  variable  can hold any number of bytes of data.  The
3162                     data can be text or binary.  The value is represented  by
3163                     the  base64  encoding  of the data.  If -Z is also speci‐
3164                     fied, the size in bytes of the data in the buffer will be
3165                     determined  by  the  size associated with the -Z.  If the
3166                     base64 string assigned results in more data, it  will  be
3167                     truncated.  Otherwise, it will be filled with bytes whose
3168                     value is zero.  The printf format %B can be used to  out‐
3169                     put  the actual data in this buffer instead of the base64
3170                     encoding of the data.
3171              -h     Used within type definitions to add information when gen‐
3172                     erating  information  about  the  sub-variable on the man
3173                     page.  It is ignored when used outside of a type  defini‐
3174                     tion.   When  used  with -f the information is associated
3175                     with the corresponding discipline function.
3176              -i     Declares vname to be represented internally  as  integer.
3177                     The  right  hand side of an assignment is evaluated as an
3178                     arithmetic expression when assigning to an integer.  If n
3179                     is  non-zero, it defines the output arithmetic base, oth‐
3180                     erwise the output base will be ten.
3181              -l     Used with -i, -E or -F, to indicate long integer, or long
3182                     float.   Otherwise,  all  upper-case  characters are con‐
3183                     verted to lower-case.   The  upper-case  option,  -u,  is
3184                     turned off.  Equivalent to -M tolower .
3185              -m     moves  or renames the variable.  The value is the name of
3186                     a variable whose value will be moved to vname.  The orig‐
3187                     inal  variable  will  be  unset.  Cannot be used with any
3188                     other options.
3189              -n     Declares vname to be a reference to  the  variable  whose
3190                     name  is defined by the value of variable vname.  This is
3191                     usually used to reference a variable  inside  a  function
3192                     whose  name  has  been  passed as an argument.  Cannot be
3193                     used with any other options.
3194              -p     The name, attributes and values for the given vnames  are
3195                     written  on standard output in a form that can be used as
3196                     shell input.  If +p is specified, then the values are not
3197                     displayed.
3198              -r     The given vnames are marked readonly and these names can‐
3199                     not be changed by subsequent assignment.
3200              -s     When given along  with  -i,  restricts  integer  size  to
3201                     short.
3202              -t     Tags  the variables.  Tags are user definable and have no
3203                     special meaning to the shell.
3204              -u     When given along with  -i,  specifies  unsigned  integer.
3205                     Otherwise, all lower-case characters are converted to up‐
3206                     per-case.  The lower-case  option,  -l,  is  turned  off.
3207                     Equivalent to -M toupper .
3208              -x     The  given  vnames are marked for automatic export to the
3209                     environment of subsequently-executed commands.  Variables
3210                     whose names contain a .  cannot be exported.
3211
3212              The  -i,  -F,  -E, and -X options cannot be specified along with
3213              -R, -L, or -Z.  The -b option cannot be specified along with -L,
3214              -u,  or  -l.   The -f, -m, -n, and -T options cannot be used to‐
3215              gether with any other option.
3216
3217              Using + rather than - causes these options to be turned off.  If
3218              no  vname  arguments are given, a list of vnames (and optionally
3219              the values) of the variables is printed.  (Using + rather than -
3220              keeps  the  values  from  being  printed.)  The -p option causes
3221              typeset followed by the option letters to be printed before each
3222              name  rather than the names of the options.  If any option other
3223              than -p is given, only those variables which  have  all  of  the
3224              given options are printed.  Otherwise, the vnames and attributes
3225              of all variables that have attributes are printed.
3226
3227       ulimit [ -HSaMctdfxlqenupmrbiswTv ] [ limit ]
3228              Set or display a resource limit.  The available resource  limits
3229              are  listed  below.   Many systems do not support one or more of
3230              these limits.  The limit for a specified resource  is  set  when
3231              limit  is  specified.  The value of limit can be a number in the
3232              unit specified below with each resource, or the value unlimited.
3233              The -H and -S options specify whether the hard limit or the soft
3234              limit for the given resource is set.  A hard limit cannot be in‐
3235              creased once it is set.  A soft limit can be increased up to the
3236              value of the hard limit.  If neither the H nor S option is spec‐
3237              ified, the limit applies to both.  The current resource limit is
3238              printed when limit is omitted.  In this case, the soft limit  is
3239              printed  unless  H is specified.  When more than one resource is
3240              specified, then the limit name and unit is  printed  before  the
3241              value.
3242              -a     Lists all of the current resource limits.
3243              -b     The socket buffer size in bytes.
3244              -c     The number of 512-byte blocks on the size of core dumps.
3245              -d     The number of K-bytes on the size of the data area.
3246              -e     The scheduling priority.
3247              -f     The  number of 512-byte blocks on files that can be writ‐
3248                     ten by the current process or by child  processes  (files
3249                     of any size may be read).
3250              -i     The signal queue size.
3251              -l     The locked address space in K-bytes.
3252              -M     The address space limit in K-bytes.
3253              -m     The number of K-bytes on the size of physical memory.
3254              -n     The number of file descriptors plus 1.
3255              -p     The number of 512-byte blocks for pipe buffering.
3256              -q     The message queue size in K-bytes.
3257              -r     The max real-time priority.
3258              -s     The number of K-bytes on the size of the stack area.
3259              -T     The number of threads.
3260              -t     The number of CPU seconds to be used by each process.
3261              -u     The number of processes.
3262              -v     The number of K-bytes for virtual memory.
3263              -w     The swap size in K-bytes.
3264              -x     The number of file locks.
3265
3266              If no option is given, -f is assumed.
3267
3268       umask [ -S ] [ mask ]
3269              The user file-creation mask is set to mask (see umask(2)).  mask
3270              can either be an octal number or a symbolic value  as  described
3271              in  chmod(1).  If a symbolic value is given, the new umask value
3272              is the complement of the result of applying mask to the  comple‐
3273              ment  of the previous umask value.  If mask is omitted, the cur‐
3274              rent value of the mask is printed.  The  -S  option  causes  the
3275              mode  to be printed as a symbolic value.  Otherwise, the mask is
3276              printed in octal.
3277
3278       unalias [ -a ] name ...
3279              The aliases given by the list of  names  are  removed  from  the
3280              alias list.  The -a option causes all the aliases to be unset.
3281
3282unset [ -fnv ] vname ...
3283              The  variables given by the list of vnames are unassigned, i.e.,
3284              except for sub-variables within a type,  their  values  and  at‐
3285              tributes  are  erased.   For sub-variables of a type, the values
3286              are reset to the default value from the type definition.   Read‐
3287              only  variables  cannot be unset.  If the -f option is set, then
3288              the names refer to function names.  If the  -v  option  is  set,
3289              then the names refer to variable names.  The -f option overrides
3290              -v.  If -n is set and name is a name reference, then  name  will
3291              be  unset  rather than the variable that it references.  The de‐
3292              fault is equivalent to -v.  Unsetting LINENO, MAILCHECK, OPTARG,
3293              OPTIND,  RANDOM,  SECONDS,  TMOUT,  and  _ removes their special
3294              meaning even if they are subsequently assigned to.
3295
3296       wait [ job ... ]
3297              Wait for the specified job and report  its  termination  status.
3298              If  job  is not given, then all currently active child processes
3299              are waited for.  The exit status from this command  is  that  of
3300              the last process waited for if job is specified; otherwise it is
3301              zero.  See Jobs for a description of the format of job.
3302
3303       whence [ -afpqv ] name ...
3304              For each name, indicate how it would be interpreted if used as a
3305              command name.
3306              The  -v  option  produces  a more verbose report.  The -f option
3307              skips the search for functions.   The  -p  option  does  a  path
3308              search  for  name even if name is an alias, a function, or a re‐
3309              served word.  The -p option turns off the -v option.  The -q op‐
3310              tion causes whence to enter quiet mode.  whence will return zero
3311              if all arguments are built-ins, functions, or are programs found
3312              on  the  path.   The  -a  option is similar to the -v option but
3313              causes all interpretations of the given name to be reported.
3314
3315   Invocation.
3316       If the shell is invoked by exec(2), initialization depends on  argument
3317       zero ($0) as follows.  If the first character of $0 is -, or the -l op‐
3318       tion is given on the invocation command line, then the shell is assumed
3319       to be a login shell.  If the basename of the command path in $0 is rsh,
3320       rksh, or krsh, then the shell becomes restricted.  If the  basename  is
3321       sh  or  rsh,  or the -o posix option is given on the invocation command
3322       line, then the shell is initialized in full POSIX compliance mode  (see
3323       the  set  builtin  command above for more information).  After this, if
3324       the shell was assumed to be a  login  shell,  commands  are  read  from
3325       /etc/profile and then from $HOME/.profile if it exists.  Alternatively,
3326       the option -l causes the shell to be treated as a login  shell.   Next,
3327       for interactive shells, commands are read from the file named by ENV if
3328       the file exists, its name being determined by performing parameter  ex‐
3329       pansion, command substitution, and arithmetic substitution on the value
3330       of that environment variable.  If the -s option is not present and  arg
3331       and  a  file by the name of arg exists, then it reads and executes this
3332       script.  Otherwise, if the first arg does  not  contain  a  /,  a  path
3333       search  is  performed  on  the  first  arg to determine the name of the
3334       script to execute.  The script arg must have execute permission and any
3335       setuid and setgid settings will be ignored.  If the script is not found
3336       on the path, arg is processed as if it  named  a  built-in  command  or
3337       function.  Commands are then read as described below; the following op‐
3338       tions are interpreted by the shell when it is invoked:
3339
3340       -D      A list of all double quoted strings that are preceded  by  a  $
3341               will  be  printed  on  standard output and the shell will exit.
3342               This set of strings will be  subject  to  language  translation
3343               when  the  locale  is not C or POSIX.  No commands will be exe‐
3344               cuted.
3345
3346       -E or -o rc or --rc
3347               Read the file named by the ENV variable or by  $HOME/.kshrc  if
3348               not  defined after the profiles.  On by default for interactive
3349               shells. Use +E, +o rc or --norc to turn off.
3350
3351       -c      Read and execute a script from the first arg instead of a file.
3352               The  second arg, if present, becomes that script's command name
3353               ($0).  Any third and further args become positional  parameters
3354               starting at $1.
3355
3356       -s      Read  and  execute  a  script  from standard input instead of a
3357               file.  The command name ($0) cannot be set.   Any  args  become
3358               the  positional  parameters  starting  at  $1.   This option is
3359               forced on if no arg is given and is ignored if -c is also spec‐
3360               ified.
3361
3362       -i or -o interactive or --interactive
3363               If  the  -i  option is present or if the shell's standard input
3364               and standard error are attached to a terminal (as told by tcge‐
3365               tattr(3)),  then  this shell is interactive.  In this case TERM
3366               is ignored (so that kill 0 does not kill an interactive  shell)
3367               and INTR is caught and ignored (so that wait is interruptible).
3368               In all cases, QUIT is ignored by the shell.
3369
3370       -r or -o restricted or --restricted
3371               If the -r option is present, the shell is a restricted shell.
3372
3373       The remaining options and arguments are described under the set command
3374       above.  An optional - as the first argument is ignored.
3375
3376   Rksh Only.
3377       Rksh is used to set up login names and execution environments whose ca‐
3378       pabilities are more controlled than those of the standard  shell.   The
3379       actions  of rksh are identical to those of ksh, except that the follow‐
3380       ing are disallowed:
3381              unsetting the restricted option,
3382              changing directory (see cd(1)),
3383              setting or unsetting the value  or  attributes  of  SHELL,  ENV,
3384              FPATH, or PATH,
3385              specifying path or command names containing /,
3386              redirecting output (>, >|, <>, and >>),
3387              adding or deleting built-in commands,
3388              using command -p to invoke a command.
3389
3390       The  restrictions  above  are enforced after .profile and the ENV files
3391       are interpreted.
3392
3393       When a command to be executed is found to be a  shell  procedure,  rksh
3394       invokes ksh to execute it.  Thus, it is possible to provide to the end-
3395       user shell procedures that have access to the full power of  the  stan‐
3396       dard  shell, while imposing a limited menu of commands; this scheme as‐
3397       sumes that the end-user does not have write and execute permissions  in
3398       the same directory.
3399
3400       The  net  effect  of these rules is that the writer of the .profile has
3401       complete control over user actions, by performing guaranteed setup  ac‐
3402       tions  and  leaving  the user in an appropriate directory (probably not
3403       the login directory).
3404
3405       The system administrator often sets up a directory of  commands  (e.g.,
3406       /usr/rbin) that can be safely invoked by rksh.
3407

EXIT STATUS

3409       Errors detected by the shell, such as syntax errors, cause the shell to
3410       return a non-zero exit status.  If the shell is being used non-interac‐
3411       tively,  then execution of the shell file is abandoned unless the error
3412       occurs inside a subshell in which case the subshell is abandoned.  Oth‐
3413       erwise,  the shell returns the exit status of the last command executed
3414       (see also the exit command above).  Run time  errors  detected  by  the
3415       shell are reported by printing the command or function name and the er‐
3416       ror condition.  If the line  number  that  the  error  occurred  on  is
3417       greater than one, then the line number is also printed in square brack‐
3418       ets ([]) after the command or function name.
3419

FILES

3421       /etc/profile
3422              The system wide initialization file, executed for login shells.
3423
3424       $HOME/.profile
3425              The personal initialization file, executed for login shells  af‐
3426              ter /etc/profile.
3427
3428       $HOME/.kshrc
3429              Default  personal  initialization file, executed for interactive
3430              shells when ENV is not set.
3431
3432       /etc/suid_profile
3433              Alternative initialization file, executed instead  of  the  per‐
3434              sonal  initialization  file  when the real and effective user or
3435              group id do not match.
3436
3437       /dev/null
3438              NULL device
3439

SEE ALSO

3441       cat(1), cd(1), chmod(1), cut(1), date(1), egrep(1), echo(1),  emacs(1),
3442       env(1),  fgrep(1),  gmacs(1),  grep(1),  pfexec(1),  stty(1),  test(1),
3443       umask(1),  vi(1),  dup(2),  exec(2),  fork(2),  getpwnam(3),  ioctl(2),
3444       lseek(2),   paste(1),   pathconf(2),   pipe(2),  sysconf(3),  umask(2),
3445       ulimit(2), wait(2), strftime(3), wctrans(3),  rand(3),  a.out(5),  pro‐
3446       file(5), environ(7).
3447
3448       Morris  I. Bolsky and David G. Korn, The New KornShell Command and Pro‐
3449       gramming Language, Prentice Hall, 1995.
3450
3451       POSIX - Part 2: Shell and  Utilities,  IEEE  Std  1003.2-1992,  ISO/IEC
3452       9945-2, IEEE, 1993.
3453

CAVEATS

3455       If  a command is executed, and then a command with the same name is in‐
3456       stalled in a directory in the search path before  the  directory  where
3457       the  original  command  was  found, the shell will continue to exec the
3458       original command.  Use the hash command or the -t option of  the  alias
3459       command to correct this situation.
3460
3461       Some very old shell scripts contain a ^ as a synonym for the pipe char‐
3462       acter |.
3463
3464       Using the hist built-in command within a compound  command  will  cause
3465       the whole command to disappear from the history file.
3466
3467       The  built-in  command  . file reads the whole file before any commands
3468       are executed.  Therefore, alias and unalias commands in the  file  will
3469       not apply to any commands defined in the file.
3470
3471       Traps  are  not  processed  while  a  job  is  waiting for a foreground
3472       process.  Thus, a trap on CHLD won't be executed until  the  foreground
3473       job terminates.
3474
3475       It  is  a good idea to leave a space after the comma operator in arith‐
3476       metic expressions to prevent the comma from being  interpreted  as  the
3477       decimal point character in certain locales.
3478
3479
3480
3481                                                                        KSH(1)
Impressum