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

EXIT STATUS

3971       Errors detected by the shell, such as syntax errors, cause the shell to
3972       return a non-zero exit status.  If the shell is being used non-interac‐
3973       tively, then execution of the shell file is abandoned unless the  error
3974       occurs inside a subshell in which case the subshell is abandoned.  Oth‐
3975       erwise, the shell returns the exit status of the last command  executed
3976       (see  also  the  exit  command above).  Run time errors detected by the
3977       shell are reported by printing the command or function name and the er‐
3978       ror  condition.   If  the  line  number  that  the error occurred on is
3979       greater than one, then the line number is also printed in square brack‐
3980       ets ([]) after the command or function name.
3981

FILES

3983       /etc/profile
3984              The system wide initialization file, executed for login shells.
3985
3986       $HOME/.profile
3987              The  personal initialization file, executed for login shells af‐
3988              ter /etc/profile.
3989
3990       $HOME/.kshrc
3991              Default personal initialization file, executed  for  interactive
3992              shells when ENV is not set.
3993
3994       /etc/suid_profile
3995              Alternative  initialization  file,  executed instead of the per‐
3996              sonal initialization file when the real and  effective  user  or
3997              group ID do not match.
3998
3999       /dev/null
4000              NULL device
4001

SEE ALSO

4003       cat(1),  cd(1), chmod(1), cut(1), date(1), egrep(1), echo(1), emacs(1),
4004       env(1), fgrep(1), gmacs(1), grep(1), stty(1), test(1), umask(1), vi(1),
4005       dup(2),  exec(2),  fork(2),  getpwnam(3), ioctl(2), lseek(2), paste(1),
4006       pathconf(2), pipe(2), sysconf(3), umask(2), ulimit(2),  wait(2),  strf‐
4007       time(3), wctrans(3), rand(3), a.out(5), profile(5), environ(7).
4008
4009       Morris  I. Bolsky and David G. Korn, The New KornShell Command and Pro‐
4010       gramming Language, Prentice Hall, 1995.
4011
4012       POSIX - Part 2: Shell and  Utilities,  IEEE  Std  1003.2-1992,  ISO/IEC
4013       9945-2, IEEE, 1993.
4014

CAVEATS

4016       If  a command is executed, and then a command with the same name is in‐
4017       stalled in a directory in the search path before  the  directory  where
4018       the  original  command  was  found, the shell will continue to exec the
4019       original command.  Use the hash command or the -t option of  the  alias
4020       command to correct this situation.
4021
4022       Using  the  hist  built-in command within a compound command will cause
4023       the whole command to disappear from the history file.
4024
4025       The built-in command . file reads the whole file  before  any  commands
4026       are  executed.   Therefore, alias and unalias commands in the file will
4027       not apply to any commands defined in the file.
4028
4029       Traps are not processed  while  a  job  is  waiting  for  a  foreground
4030       process.   Thus,  a trap on CHLD won't be executed until the foreground
4031       job terminates.
4032
4033       In locales that use a multibyte character set such as UTF-8, the  KEYBD
4034       trap is only triggered for ASCII characters (1-127).
4035
4036       It  is  a good idea to leave a space after the comma operator in arith‐
4037       metic expressions to prevent the comma from being  interpreted  as  the
4038       decimal point character in certain locales.
4039
4040
4041
4042                                                                        KSH(1)
Impressum