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  the  empty string.  The contents of the line read from stan‐
123              dard input is saved in the variable REPLY.  The list is executed
124              for  each selection until a break or end-of-file is encountered.
125              If the REPLY variable is set to the empty string by  the  execu‐
126              tion of list, then the selection list is printed before display‐
127              ing the PS3 prompt for 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 the empty string.  When subscript is @, same as above, ex‐
554              cept that when used  in  double  quotes,  each  array  subscript
555              yields  a separate argument.  When subscript is of the form sub1
556              ..  sub2 it expands to the list of subscripts between  sub1  and
557              sub2 inclusive 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 has a non-empty value, then substitute
567              its value; otherwise substitute word.
568
569       ${parameter:=word}
570              If parameter is not set or has the empty string value, then  set
571              it to word; the value of the parameter is then substituted.  Po‐
572              sitional parameters may not be assigned to in this way.
573
574       ${parameter:?word}
575              If parameter is set and has a non-empty value,  then  substitute
576              its value; otherwise, print word and exit from the shell (if not
577              interactive).  If word is omitted then  a  standard  message  is
578              printed.
579
580       ${parameter:+word}
581              If  parameter  is  set and has a non-empty value then substitute
582              word; otherwise substitute the empty string.
583
584       In the above, word is not evaluated unless it is to be used as the sub‐
585       stituted  string,  so  that,  in the following example, pwd is executed
586       only if d is not set or has the empty string value:
587
588              print ${d:-$(pwd)}
589
590       If the colon (:) is omitted from the above expressions, then the  shell
591       only checks whether parameter is set or not.
592
593       ${parameter:offset:length}
594       ${parameter:offset}
595              Expands to the portion of the value of parameter starting at the
596              character (counting from 0) determined by expanding offset as an
597              arithmetic expression and consisting of the number of characters
598              determined by the arithmetic expression defined by  length.   In
599              the second form, the remainder of the value is used.  If A nega‐
600              tive offset counts backwards from the end  of  parameter.   Note
601              that  one or more blanks is required in front of a minus sign to
602              prevent the shell from interpreting the operator as :-.  If  pa‐
603              rameter  is  * or @, or is an array name indexed by * or @, then
604              offset and length refer to the array index and  number  of  ele‐
605              ments  respectively.  A negative offset is taken relative to one
606              greater than the highest subscript for indexed arrays.  The  or‐
607              der for associative arrays is unspecified.
608
609       ${parameter#pattern}
610       ${parameter##pattern}
611              If  the  shell pattern matches the beginning of the value of pa‐
612              rameter, then the value of this expansion is the  value  of  the
613              parameter  with the matched portion deleted; otherwise the value
614              of this parameter is substituted.  In the first form the  small‐
615              est  matching  pattern  is  deleted  and  in the second form the
616              largest matching pattern is deleted.  When parameter is @, *, or
617              an array variable with subscript @ or *, the substring operation
618              is applied to each element in turn.
619
620       ${parameter%pattern}
621       ${parameter%%pattern}
622              If the shell pattern matches the end of the value of  parameter,
623              then  the  value of this expansion is the value of the parameter
624              with the matched part deleted; otherwise substitute the value of
625              parameter.   In  the first form the smallest matching pattern is
626              deleted and in the second form the largest matching  pattern  is
627              deleted.  When parameter is @, *, or an array variable with sub‐
628              script @ or *, the substring operation is applied to  each  ele‐
629              ment in turn.
630
631       ${parameter/pattern/string}
632       ${parameter//pattern/string}
633       ${parameter/#pattern/string}
634       ${parameter/%pattern/string}
635              Expands parameter and replaces the longest match of pattern with
636              the given string.  Each occurrence of \n in string  is  replaced
637              by  the  portion  of parameter that matches the n-th subpattern.
638              In the first form, only the first occurrence of pattern  is  re‐
639              placed.   In the second form, each match for pattern is replaced
640              by the given string.  The third form restricts the pattern match
641              to  the  beginning of the string while the fourth form restricts
642              the pattern match to the end of  the  string.   When  string  is
643              empty,  the pattern will be deleted and the / in front of string
644              may be omitted.  When parameter is @, *, or  an  array  variable
645              with  subscript @ or *, the substitution operation is applied to
646              each element in turn.  In this case, the string portion of  word
647              will be re-evaluated for each element.
648
649   Shell Variables.
650       The following parameters are automatically set by the shell:
651              #      The number of positional parameters in decimal.
652
653              -      Options supplied to the shell on invocation or by the set
654                     command.
655
656              ?      The exit status returned by the  last  executed  command.
657                     Its  meaning  depends on the command or function that de‐
658                     fines it, but there are conventions that  other  commands
659                     often  depend  on:  zero  typically  means  'success'  or
660                     'true', one typically means 'non-success' or 'false', and
661                     a value greater than one typically indicates some kind of
662                     error. Only the 8 least significant bits of $? (values  0
663                     to  255)  are preserved when the exit status is passed on
664                     to a parent process, but within the same (sub)shell envi‐
665                     ronment,  it  is  a  signed integer value with a range of
666                     possible values as shown by the commands getconf  INT_MIN
667                     and getconf INT_MAX. Shell functions that run in the cur‐
668                     rent environment may return status values in this range.
669
670              $      The process ID of the main shell process. Note that  this
671                     value will not change in a subshell, even if the subshell
672                     runs in a different process.  See also .sh.pid.
673
674              _      Initially, the value of _ is an absolute pathname of  the
675                     shell  or script being executed as passed in the environ‐
676                     ment.  Subsequently it is assigned the last  argument  of
677                     the previous command.  This parameter is not set for com‐
678                     mands which are asynchronous.   This  parameter  is  also
679                     used  to  hold  the  name  of the matching MAIL file when
680                     checking for mail.  While defining a compound variable or
681                     a  type,  _ is initialized as a reference to the compound
682                     variable or type.  When a discipline function is invoked,
683                     _  is  initialized as a reference to the variable associ‐
684                     ated with the call to this function.  Finally when  _  is
685                     used  as the name of the first variable of a type defini‐
686                     tion, the new type is derived from the type of the  first
687                     variable. (See Type Variables  below.)
688
689              !      The  process  ID  or  the pool name and job number of the
690                     last background command invoked or the  most  recent  job
691                     put  in  the  background  with  the  bg built-in command.
692                     Background jobs started in a named pool will  be  in  the
693                     form  pool.number  where pool is the pool name and number
694                     is the job number within that pool.
695
696              .sh.command
697                     When processing a DEBUG trap, this variable contains  the
698                     current  command line that is about to run.  The value is
699                     in the same format as the output generated by the  xtrace
700                     option (minus the preceding PS4 prompt).
701
702              .sh.edchar
703                     This  variable contains the value of the keyboard charac‐
704                     ter (or sequence of characters if the first character  is
705                     an  ESC, ASCII 033) that has been entered when processing
706                     a KEYBD trap (see Key Bindings below).  If the  value  is
707                     changed  as  part  of the trap action, then the new value
708                     replaces the key (or key sequence) that caused the trap.
709
710              .sh.edcol
711                     The character position of the cursor at the time  of  the
712                     most recent KEYBD trap.
713
714              .sh.edmode
715                     Upon  executing  a  KEYBD  trap action, the value of this
716                     variable is set to the ESC control character if the shell
717                     is  in vi insert mode (See Vi Editing Mode  below), or to
718                     the empty string value otherwise.
719
720              .sh.edtext
721                     The characters in the input buffer at  the  time  of  the
722                     most  recent  KEYBD trap.  The variable is unset when not
723                     processing a KEYBD trap.
724
725              .sh.file
726                     The pathname of the file that contains the  current  com‐
727                     mand.
728
729              .sh.fun
730                     The name of the current function that is being executed.
731
732              .sh.level
733                     Set  to  the  current  call  depth  of  functions and dot
734                     scripts.  Normally, this variable is read-only, but while
735                     executing  a  DEBUG  trap,  its  value  may be changed to
736                     switch the current function scope to that of  the  speci‐
737                     fied  level  for  the duration of the trap run, making it
738                     possible to access a parent scope for debugging purposes.
739                     When  trap execution ends, the variable and the scope are
740                     restored.  It is an error to assign a value lower than  0
741                     (the global scope) or higher than the current call depth.
742
743              .sh.lineno
744                     Set during a DEBUG trap to the line number for the caller
745                     of each function.
746
747              .sh.match
748                     An indexed array which stores the most recent  match  and
749                     subpattern matches after conditional pattern matches that
750                     match and after variables expansions using the  operators
751                     #,  %,  or /.  The 0-th element stores the complete match
752                     and the i-th.  element stores the i-th submatch.  For //,
753                     the  array  is  two-dimensional, with the first subscript
754                     indicating the most recent match  and  subpattern  match,
755                     and  the  second  subscript indicating which match with 0
756                     representing the first match.  The .sh.match variable be‐
757                     comes  unset  when  the variable that has expanded is as‐
758                     signed a new value.
759
760              .sh.math
761                     Used for defining arithmetic  functions  (see  Arithmetic
762                     Evaluation  below)  and  stores  the list of user defined
763                     arithmetic functions.
764
765              .sh.name
766                     Set to the name of the variable at the time that a disci‐
767                     pline function is invoked.
768
769              .sh.subscript
770                     Set  to  the  name  subscript of the variable at the time
771                     that a discipline function is invoked.
772
773              .sh.subshell
774                     The current depth for subshells and command substitution.
775
776              .sh.pid
777                     Set to the process ID of the current shell process.   Un‐
778                     like $$, this is updated in a subshell when it forks into
779                     a new process.  Note that a virtual subshell may have  to
780                     fork mid-execution due to various system- and implementa‐
781                     tion-dependent requirements, so the value should  not  be
782                     counted  on  to  remain  the same from one command to the
783                     next.  If a persistent process ID is required for a  sub‐
784                     shell,  it  must  be  ensured  it  is  running in its own
785                     process first.  Any attempt to set a process limit  using
786                     the  ulimit built-in command, such as ulimit -t unlimited
787                     2>/dev/null, is a reliable way to make a subshell fork if
788                     it hasn't already.
789
790              .sh.ppid
791                     Set  to the process ID of the parent of the current shell
792                     process.  Unlike $PPID, this is  updated  in  a  subshell
793                     when  it  forks into a new process.  The same note as for
794                     .sh.pid applies.
795
796              .sh.value
797                     Set to the value of the variable at the time that the set
798                     or  append  discipline  function is invoked.  When a user
799                     defined arithmetic function  is  invoked,  the  value  of
800                     .sh.value  is  saved  and .sh.value is set to long double
801                     precision floating point.  .sh.value is restored when the
802                     function returns.
803
804              .sh.version
805                     Set to a value that identifies the version of this shell.
806
807              COLUMNS
808                     Width of the terminal window in character positions.  Up‐
809                     dated automatically at initialization and on receiving  a
810                     SIGWINCH  signal.  The shell uses the value to define the
811                     width of the edit window for the shell edit modes and for
812                     printing select lists.
813
814              KSH_VERSION
815                     A name reference to .sh.version.
816
817              LINENO The current line number within the script or function be‐
818                     ing executed.
819
820              LINES  Height of the terminal window in lines.  Updated automat‐
821                     ically at initialization and on receiving a SIGWINCH sig‐
822                     nal.  The shell uses the value to  determine  the  column
823                     length for printing select lists: they are printed verti‐
824                     cally until about two thirds of LINES lines are filled.
825
826              OLDPWD The previous working directory set by the cd command.
827
828              OPTARG The value of the last option argument  processed  by  the
829                     getopts built-in command.
830
831              OPTIND The  index  of  the last option argument processed by the
832                     getopts built-in command.
833
834              PPID   The process ID of the parent of the main  shell  process.
835                     Note  that this value will not change in a subshell, even
836                     if the subshell runs in a different  process.   See  also
837                     .sh.ppid.
838
839              PWD    The present working directory set by the cd command.
840
841              RANDOM Each  time this variable is referenced, a random integer,
842                     uniformly distributed between 0 and 32767, is  generated.
843                     The  sequence of random numbers can be initialized by as‐
844                     signing a numeric value to RANDOM.
845
846              REPLY  This variable is set by the select statement and  by  the
847                     read built-in command when no arguments are supplied.
848
849              SECONDS
850                     Each time this variable is referenced, the number of sec‐
851                     onds since shell invocation is returned.  If  this  vari‐
852                     able  is  assigned  a value, then the value returned upon
853                     reference will be the value that was  assigned  plus  the
854                     number of seconds since the assignment.
855
856              SHLVL  An integer variable that is incremented and exported each
857                     time the shell is invoked.  If SHLVL is not in the  envi‐
858                     ronment when the shell is invoked, it is set to 1.
859
860       The following variables are used by the shell:
861              CDPATH The search path for the cd command.
862
863              EDITOR If  the  VISUAL  variable  is  not set, the value of this
864                     variable will be checked for  certain  patterns  and  the
865                     corresponding  editing  option  will  be turned on as de‐
866                     scribed with VISUAL below.
867
868              ENV    If this variable is set, then parameter  expansion,  com‐
869                     mand substitution, and arithmetic expansion are performed
870                     on the value to generate the pathname of the script  that
871                     will  be executed when the shell is invoked interactively
872                     (see Invocation below).  This file is typically used  for
873                     alias  and  function  definitions.   The default value is
874                     $HOME/.kshrc.  On systems  that  support  a  system  wide
875                     /etc/ksh.kshrc  initialization file, if the filename gen‐
876                     erated by the expansion of ENV begins with  /./  or  ././
877                     the system wide initialization file will not be executed.
878
879              FCEDIT Obsolete  name  for  the default editor name for the hist
880                     command.  FCEDIT is not used when HISTEDIT is set.
881
882              FIGNORE
883                     A pattern that defines the set of filenames that will  be
884                     ignored when performing filename matching.
885
886              FPATH  The  search  path for function definitions.  The directo‐
887                     ries in this path are searched for a file with  the  same
888                     name  as the function or command when a function with the
889                     -u attribute is referenced and  when  a  command  is  not
890                     found.   If an executable file with the name of that com‐
891                     mand is found, then it is read and executed in  the  cur‐
892                     rent  environment.   Unlike  PATH,  the current directory
893                     must be represented explicitly by .  rather than by adja‐
894                     cent : characters or a beginning or ending :.
895
896              histchars
897                     This  variable  can  be used to specify up to three ASCII
898                     characters that control history  expansion  (see  History
899                     Expansion  below).   The  first  (default: !) signals the
900                     start of a history expansion.  The second (default: ^) is
901                     used  for  short-form substitutions.  The third (default:
902                     #), when found as the first character of a  word,  causes
903                     history expansion to be skipped for the rest of the words
904                     on the line.  Multi-byte characters (e.g. UTF-8) are  not
905                     supported and produce undefined results.
906
907              HISTCMD
908                     Number of the current command in the history file.
909
910              HISTEDIT
911                     Name for the default editor name for the hist command.
912
913              HISTFILE
914                     If  this  variable is set when the shell is invoked, then
915                     the value is the pathname of the file that will  be  used
916                     to  store  the  command history (see Command Re-entry be‐
917                     low).
918
919              HISTSIZE
920                     If this variable is set when the shell is  invoked,  then
921                     the number of previously entered commands that are acces‐
922                     sible by this shell will be greater than or equal to this
923                     number.  The default is 512.
924
925              HOME   The default argument (home directory) for the cd command.
926
927              IFS    Internal  field separators, normally space, tab, and new-
928                     line that are used to separate  the  results  of  command
929                     substitution  or  parameter  expansion  and  to  separate
930                     fields with the built-in command read.  The first charac‐
931                     ter of the IFS variable is used to separate arguments for
932                     the "$*" expansion (see Quoting below).  Each single  oc‐
933                     currence  of  an  IFS character in the string to be split
934                     that is not in the isspace character class, and any adja‐
935                     cent  characters in IFS that are in the isspace character
936                     class, delimit a field.  One or more  characters  in  IFS
937                     that  belong  to  the  isspace  character class delimit a
938                     field.  In addition, if the same  isspace  character  ap‐
939                     pears consecutively inside IFS and the posix shell option
940                     is not on, this character is treated as if it were not in
941                     the  isspace  class - for example, if IFS consists of two
942                     tab characters, then two adjacent tab characters  delimit
943                     an empty field.
944
945              JOBMAX This  variable  defines  the maximum number running back‐
946                     ground jobs that can run at a time.  When this  limit  is
947                     reached, the shell will wait for a job to complete before
948                     starting a new job.
949
950              LANG   This variable determines the locale category for any cat‐
951                     egory  not specifically selected with a variable starting
952                     with LC_ or LANG.
953
954              LC_ALL This variable overrides the value of  the  LANG  variable
955                     and any other LC_ variable.
956
957              LC_COLLATE
958                     This  variable determines the locale category for charac‐
959                     ter collation information.
960
961              LC_CTYPE
962                     This variable determines the locale category for  charac‐
963                     ter  handling  functions.   It  determines  the character
964                     classes for pattern matching (see Pathname Expansion  be‐
965                     low).
966
967              LC_NUMERIC
968                     This variable determines the locale category for the dec‐
969                     imal point character.
970
971              MAIL   If this variable is set to the name of a  mail  file  and
972                     the  MAILPATH variable is not set, then the shell informs
973                     the user of arrival of mail in the specified file.
974
975              MAILCHECK
976                     This variable specifies how often (in seconds) the  shell
977                     will check for changes in the modification time of any of
978                     the files specified by the MAILPATH  or  MAIL  variables.
979                     The  default  value  is  600  seconds.  When the time has
980                     elapsed the shell will  check  before  issuing  the  next
981                     prompt.
982
983              MAILPATH
984                     A  colon  (  :  )  separated list of file names.  If this
985                     variable is set, then the shell informs the user  of  any
986                     modifications  to  the specified files that have occurred
987                     within the last MAILCHECK seconds.  Each file name can be
988                     followed by a ?  and a message that will be printed.  The
989                     message will undergo parameter expansion, command substi‐
990                     tution, and arithmetic expansion with the variable $_ de‐
991                     fined as the name of the file that has changed.  The  de‐
992                     fault message is you have mail in $_.
993
994              PATH   The  search path for commands (see Execution below).  The
995                     user may not change PATH if executing under rksh  (except
996                     in .profile).
997
998              PS1    Every  time  a new command line is started on an interac‐
999                     tive shell, the value of this variable is expanded to re‐
1000                     solve  backslash  escaping,  parameter expansion, command
1001                     substitution, and arithmetic expansion.  The  result  de‐
1002                     fines  the  primary  prompt string for that command line.
1003                     The default is ``$ ''.  The character !  in  the  primary
1004                     prompt string is replaced by the command number (see Com‐
1005                     mand Re-entry below).  Two successive  occurrences  of  !
1006                     will  produce  a  single  !   when  the  prompt string is
1007                     printed.  Note that any terminal escape sequences used in
1008                     the  PS1 prompt thus need every instance of !  in them to
1009                     be changed to !!.
1010
1011              PS2    Secondary prompt string, by default ``> ''.
1012
1013              PS3    Selection prompt string used within a select loop, by de‐
1014                     fault ``#? ''.
1015
1016              PS4    The  value  of  this  variable  is expanded for parameter
1017                     evaluation, command substitution, and  arithmetic  expan‐
1018                     sion  and  precedes  each line of an execution trace.  By
1019                     default, PS4 is ``+ ''.  In addition when PS4  is  unset,
1020                     the execution trace prompt is also ``+ ''.
1021
1022              SHELL  The pathname of the shell is kept in the environment.  At
1023                     invocation, if the basename  of  this  variable  is  rsh,
1024                     rksh, or krsh, then the shell becomes restricted.
1025
1026              TIMEFORMAT
1027                     The  value  of  this parameter is used as a format string
1028                     specifying how the timing information for pipelines  pre‐
1029                     fixed  with  the  time reserved word should be displayed.
1030                     The % character introduces a format sequence that is  ex‐
1031                     panded  to a time value or other information.  The format
1032                     sequences and their meanings are as follows.
1033                     %%        A literal %.
1034                     %[p][l]R  The elapsed time in seconds.
1035                     %[p][l]U  The number of CPU seconds spent in user mode.
1036                     %[p][l]S  The number of CPU seconds spent in system mode.
1037                     %P        The CPU percentage, computed as (U + S) / R.
1038
1039                     The brackets denote optional portions.  The optional p is
1040                     a  digit  specifying  the  precision, the number of frac‐
1041                     tional digits after a decimal point.  A value of 0 causes
1042                     no decimal point or fraction to be output.  At most three
1043                     places after the decimal point can be  displayed;  values
1044                     of p greater than 3 are treated as 3.  If p is not speci‐
1045                     fied, the value 3 is used.
1046
1047                     The optional l specifies a longer format, including hours
1048                     if  greater  than  zero, minutes, and seconds of the form
1049                     HHhMMmSS.FFs.  The value of p determines whether  or  not
1050                     the fraction is included.  Seconds are zero-padded unless
1051                     the posix shell option is on.
1052
1053                     All other characters are  output  without  change  and  a
1054                     trailing newline is added.  If the variable is unset, the
1055                     default value, $'\nreal\t%2lR\nuser\t%2lU\nsys\t%2lS', is
1056                     used.   If  the  value is empty, no timing information is
1057                     displayed.
1058
1059              TMOUT  Terminal read timeout. If set to  a  value  greater  than
1060                     zero,  the  read built-in command and the select compound
1061                     command time out after TMOUT seconds when input is from a
1062                     terminal.   An interactive shell will issue a warning and
1063                     allow for an extra 60 second timeout grace period  before
1064                     terminating  if  a  line  is  not entered within the pre‐
1065                     scribed number of seconds while reading from a  terminal.
1066                     (Note that the shell can be compiled with a maximum bound
1067                     for this value which cannot be exceeded.)
1068
1069              VISUAL The value of this variable is scanned when the  shell  is
1070                     invoked and whenever its value is changed; if it is found
1071                     to match certain patterns, the corresponding line  editor
1072                     (see  In-line Editing Options below) is activated.  If it
1073                     matches the pattern *[Vv][Ii]*, the vi option  is  turned
1074                     on; else if it matches the pattern *gmacs*, the gmacs op‐
1075                     tion is turned on; else if it matches the pattern *macs*,
1076                     the  emacs  option is turned on.  If none of the patterns
1077                     match, emacs is turned on by default upon initializing an
1078                     interactive shell.  If the value is changed by assignment
1079                     and none of the patterns match, no options  are  changed.
1080                     The value of VISUAL overrides the value of EDITOR.
1081
1082       The  shell gives default values to PATH, PS1, PS2, PS3, PS4, MAILCHECK,
1083       FCEDIT, TMOUT and IFS, while HOME, SHELL, ENV, histchars, and MAIL  are
1084       not  set  at  all  by the shell (although HOME is set by login(1)).  On
1085       some systems MAIL and SHELL are also set by login(1).
1086
1087   Field Splitting.
1088       After parameter expansion and command substitution, the results of sub‐
1089       stitutions  are scanned for the field separator characters (those found
1090       in IFS) and split into distinct fields where such characters are found.
1091       Explicit  empty  fields ("" or ′′) are retained.  Implicit empty fields
1092       (those resulting from parameters that are unset or  have  empty  string
1093       values  or  from  command  substitutions yielding the empty string, and
1094       that are not quoted with "") are removed.
1095
1096   Brace Expansion.
1097       If the braceexpand (-B) option is set then each of the fields resulting
1098       from  IFS  are  checked to see if they contain one or more of the brace
1099       patterns {*,*}, {l1..l2} , {n1..n2} , {n1..n2% fmt} , {n1..n2  ..n3}  ,
1100       or {n1..n2 ..n3%fmt} , where * represents any character, l1,l2 are let‐
1101       ters and n1,n2,n3 are signed numbers and fmt is a format  specified  as
1102       used  by  printf.   In  each case, fields are created by prepending the
1103       characters before the { and appending the characters  after  the  }  to
1104       each  of  the  strings generated by the characters between the { and }.
1105       The resulting fields are checked to see if they  have  any  brace  pat‐
1106       terns.
1107
1108       In  the first form, a field is created for each string between { and ,,
1109       between , and ,, and between , and }.  The string represented by *  can
1110       contain  embedded  matching { and } without quoting.  Otherwise, each {
1111       and } with * must be quoted.
1112
1113       In the seconds form, l1 and l2 must both be either upper case  or  both
1114       be lower case characters in the C locale.  In this case a field is cre‐
1115       ated for each character from l1 through l2.
1116
1117       In the remaining forms, a field is created for each number starting  at
1118       n1 and continuing until it reaches n2 incrementing n1 by n3.  The cases
1119       where n3 is not specified behave as if n3 where 1 if n1<=n2 and -1 oth‐
1120       erwise.   If forms which specify %fmt any format flags, widths and pre‐
1121       cisions can be specified and fmt can  end  in  any  of  the  specifiers
1122       cdiouxX.   For  example,  {a,z}{1..5..3%02d}{b..c}x  expands  to  the 8
1123       fields, a01bx, a01cx, a04bx, a04cx, z01bx, z01cx, z04bx and z04cx.
1124
1125   Pathname Expansion.
1126       This is also known as globbing or sometimes filename generation.   Fol‐
1127       lowing splitting, each field is scanned for the characters *, ?, (, and
1128       [ unless the -f option has been set.  If one of  these  characters  ap‐
1129       pears,  then  the word is regarded as a pattern.  Each file name compo‐
1130       nent that contains any pattern character is  replaced  with  a  lexico‐
1131       graphically  sorted set of names that matches the pattern from that di‐
1132       rectory.  If no file name is found that matches the pattern, then  that
1133       component  of the filename is left unchanged unless the pattern is pre‐
1134       fixed with ∼(N), in which case it is removed as described  below.   The
1135       special  traversal  names  .  and ..  are never matched.  If FIGNORE is
1136       set, then each file name component that matches the pattern defined  by
1137       the value of FIGNORE is ignored when generating the matching filenames.
1138       If FIGNORE is not set, the character .  at the start of each file  name
1139       component  will  be  ignored  unless the first character of the pattern
1140       corresponding to this component is the character .  itself.  Note that,
1141       for uses of pattern matching other than pathname expansion, the / and .
1142       are not treated specially.
1143
1144              *      Matches any string, including  the  empty  string.   When
1145                     used  for  filename  expansion, if the globstar option is
1146                     on, an isolated pattern of two adjacent *s will match all
1147                     files  and  zero  or more directories and subdirectories.
1148                     If followed by a / then only directories and  subdirecto‐
1149                     ries will match.
1150              ?      Matches any single character.
1151              [...]  Matches  any  one  of the enclosed characters.  A pair of
1152                     characters separated by - matches any character lexically
1153                     between the pair, inclusive.  If the first character fol‐
1154                     lowing the opening [ is a !  or ^, then any character not
1155                     enclosed  is matched.  A - can be included in the charac‐
1156                     ter set by putting it as the first or last character.
1157                     Within [ and ], character classes can be  specified  with
1158                     the syntax [:class:], where class is one of the following
1159                     classes defined in the ANSI C standard (note that word is
1160                     equivalent to alnum plus the character _):
1161                     alnum  alpha  blank  cntrl  digit graph lower print punct
1162                     space upper word xdigit
1163                     Within [ and ], an equivalence  class  can  be  specified
1164                     with  the  syntax [=c=] which matches all characters with
1165                     the same primary collation weight (as defined by the cur‐
1166                     rent  locale) as the character c.  Within [ and ], [.sym‐
1167                     bol.]  matches the collating symbol symbol.
1168
1169       A pattern-list is a list of one or more patterns  separated  from  each
1170       other  with  a & or |.  A & signifies that all patterns must be matched
1171       whereas | requires that only one pattern be  matched.   Composite  pat‐
1172       terns can be formed with one or more of the following subpatterns:
1173              ?(pattern-list)
1174                     Optionally matches any one of the given patterns.
1175              *(pattern-list)
1176                     Matches zero or more occurrences of the given patterns.
1177              +(pattern-list)
1178                     Matches one or more occurrences of the given patterns.
1179              {n}(pattern-list)
1180                     Matches n occurrences of the given patterns.
1181              {m,n}(pattern-list)
1182                     Matches  from  m  to n occurrences of the given patterns.
1183                     If m is omitted, 0 will be used.  If  n  is  omitted,  at
1184                     least m occurrences will be matched.
1185              @(pattern-list)
1186                     Matches exactly one of the given patterns.
1187              !(pattern-list)
1188                     Matches anything except one of the given patterns.
1189
1190       By  default,  each  pattern or subpattern will match the longest string
1191       possible consistent with generating the longest overall match.  If more
1192       than  one  match is possible, the one starting closest to the beginning
1193       of the string will be chosen.   However, for each of the above compound
1194       patterns,  a  - can be inserted in front of the ( to cause the shortest
1195       match to the specified pattern-list to be used.
1196
1197       When pattern-list is contained within parentheses, the backslash  char‐
1198       acter  \ is treated specially even when inside a character class.   All
1199       ANSI C character escapes are recognized and match the specified charac‐
1200       ter.  In addition, the following escape sequences are recognized:
1201              \d     Matches any character in the digit class.
1202              \D     Matches any character not in the digit class.
1203              \s     Matches any character in the space class.
1204              \S     Matches any character not in the space class.
1205              \w     Matches any character in the word class.
1206              \W     Matches any character not in the word class.
1207
1208       A  pattern  of  the form %(pattern-pair(s)) is a subpattern that can be
1209       used to match nested character expressions.   Each  pattern-pair  is  a
1210       two-character  sequence that cannot contain & or |.  The first pattern-
1211       pair specifies the starting and ending characters for the match.   Each
1212       subsequent  pattern-pair represents the beginning and ending characters
1213       of a nested group that will be skipped over when counting starting  and
1214       ending  character  matches.  The behavior is unspecified when the first
1215       character of a pattern-pair is alphanumeric, except for the following:
1216              D      Causes the ending character to terminate the  search  for
1217                     this pattern without finding a match.
1218              E      Causes  the  ending character to be interpreted as an es‐
1219                     cape character.
1220              L      Causes the ending character to be interpreted as a  quote
1221                     character,  causing  all  characters  to  be ignored when
1222                     looking for a match.
1223              Q      Causes the ending character to be interpreted as a  quote
1224                     character,  causing  all characters other than any escape
1225                     character to be ignored when looking for a match.
1226
1227       Thus, %({}Q"E\), matches characters starting at { until the matching  }
1228       is found, not counting any { or } that is inside a double-quoted string
1229       or preceded by the escape character \.  Without the  {},  this  pattern
1230       matches any C language string.
1231
1232       Each  subpattern  in a composite pattern is numbered, starting at 1, by
1233       the location of the ( within the pattern.  The sequence \n, where n  is
1234       a  single digit and \n comes after the nth subpattern, matches the same
1235       string as the subpattern itself.
1236
1237       Finally, a pattern can contain subpatterns of the  form  ∼(options:pat‐
1238       tern-list),  where either options or :pattern-list can be omitted.  Un‐
1239       like the other compound patterns, these subpatterns are not counted  in
1240       the numbered subpatterns.  :pattern-list must be omitted for options F,
1241       G, N, and V below.  If options is present, it can  consist  of  one  or
1242       more of the following:
1243              +      Enable the following options.  This is the default.
1244              -      Disable the following options.
1245              E      The  remainder  of  the pattern uses extended regular ex‐
1246                     pression syntax like the -E option of  the  grep(1)  com‐
1247                     mand.
1248              F      The  remainder of the pattern uses the fixed pattern syn‐
1249                     tax of the -F option of the grep(1) command.
1250              G      The remainder of the pattern uses basic  regular  expres‐
1251                     sion syntax like the grep(1) command without options.
1252              K      The  remainder  of the pattern uses shell pattern syntax.
1253                     This is the default.
1254              N      When it is the first letter and is used with pathname ex‐
1255                     pansion,  and  no matches occur, the file pattern expands
1256                     to the empty  string  instead  of  remaining  unexpanded.
1257                     Otherwise, it is ignored.
1258              X      The  remainder  of the pattern uses augmented regular ex‐
1259                     pression syntax like the -X option of the AT&T  AST  ver‐
1260                     sion of the grep(1) command.
1261              P      The remainder of the pattern uses perl(1) regular expres‐
1262                     sion syntax.  Not all perl regular expression  syntax  is
1263                     currently implemented.
1264              V      The  remainder  of  the pattern uses System V regular ex‐
1265                     pression syntax.
1266              i      Always treat the match as case-insensitive, regardless of
1267                     the globcasedetect shell option.
1268              g      File the longest match (greedy).  This is the default.
1269              l      Left-anchor the pattern.  This is the default for K style
1270                     patterns.
1271              r      Right-anchor the pattern.  This  is  the  default  for  K
1272                     style patterns.
1273
1274       If both options and :pattern-list are specified, then the options apply
1275       only to  pattern-list.  Otherwise, these options remain in effect until
1276       they  are  disabled by a subsequent ∼(...) or at the end of the subpat‐
1277       tern containing ∼(...).
1278
1279   Quoting.
1280       Each of the metacharacters listed earlier (see Definitions above) has a
1281       special  meaning  to  the shell and causes termination of a word unless
1282       quoted.  A character may be quoted (i.e., made to stand for itself)  by
1283       preceding  it with a \.  The pair \new-line is removed.  All characters
1284       enclosed between a pair of single quote marks (′′) that is not preceded
1285       by  a  $  are  quoted.   A single quote cannot appear within the single
1286       quotes.  A single quoted string preceded by an unquoted $ is  processed
1287       as an ANSI C string except for the following:
1288              \0     Causes the remainder of the string to be ignored.
1289              \E     Equivalent to the escape character (ASCII 033),
1290              \e     Equivalent to the escape character (ASCII 033),
1291              \cx    Expands to the character control-x.
1292              \C[.name.]
1293                     Expands to the collating element name.
1294
1295       Inside  double quote marks (""), parameter and command substitution oc‐
1296       cur and \ quotes the characters \, `, ", and $.  A $ in front of a dou‐
1297       ble quoted string will be ignored in the "C" or "POSIX" locale, and may
1298       cause the string to be replaced by a locale specific string  otherwise.
1299       The meaning of $* and $@ is identical when not quoted or when used as a
1300       variable assignment value or as a file name.  However, when used  as  a
1301       command  argument,  "$*"  is  equivalent to "$1d$2d...", where d is the
1302       first character of the IFS variable, whereas "$@" is equivalent to "$1"
1303       "$2" ....  Inside grave quote marks (``), \ quotes the characters \, `,
1304       and $.  If the grave quotes occur within double  quotes,  then  \  also
1305       quotes the character ".
1306
1307       The  special  meaning  of  reserved  words or aliases can be removed by
1308       quoting any character of the reserved word.  The recognition  of  func‐
1309       tion  names or built-in command names listed below cannot be altered by
1310       quoting them.
1311
1312   Arithmetic Evaluation.
1313       The shell performs arithmetic evaluation for arithmetic  expansion,  to
1314       evaluate an arithmetic command, to evaluate an indexed array subscript,
1315       and to evaluate arguments to the built-in commands  shift  and  let  as
1316       well  as  arguments to numeric format specifiers given to print -f  and
1317       printf.  Evaluations are  performed  using  double  precision  floating
1318       point  arithmetic  or  long double precision floating point for systems
1319       that provide this data type.  Floating point constants follow the  ANSI
1320       C  programming  language floating point conventions.  The case-insensi‐
1321       tive floating point constants NaN and Inf can be used to represent "not
1322       a  number"  and infinity respectively, unless the posix shell option is
1323       on.  Integer constants follow the ANSI C programming  language  integer
1324       constant  conventions although only single byte character constants are
1325       recognized and character casts are not recognized.   In  addition  con‐
1326       stants  can  be of the form [base#]n where base is a decimal number be‐
1327       tween two and sixty-four representing the arithmetic base and  n  is  a
1328       number  in  that base.  The digits above 9 are represented by the lower
1329       case letters, the upper case letters, @, and _ respectively.  For bases
1330       less  than  or equal to 36, upper and lower case characters can be used
1331       interchangeably.
1332
1333       An arithmetic expression uses the same syntax, precedence, and associa‐
1334       tivity  of  expression as the C language.  All the C language operators
1335       that apply to floating point quantities can be used.  In addition,  the
1336       operator  **  can be used for exponentiation.  It has higher precedence
1337       than multiplication and is left associative.   In  addition,  when  the
1338       value  of an arithmetic variable or subexpression can be represented as
1339       a long integer, all C language integer  arithmetic  operations  can  be
1340       performed.   Variables  can  be referenced by name within an arithmetic
1341       expression without using the parameter expansion syntax.  When a  vari‐
1342       able is referenced, its value is evaluated as an arithmetic expression.
1343
1344       Any  of the following math library functions that are in the C math li‐
1345       brary can be used within an arithmetic expression:
1346
1347       abs acos acosh asin asinh atan atan2 atanh cbrt ceil copysign cos  cosh
1348       erf  erfc  exp  exp10  exp2 expm1 fabs fdim finite float floor fma fmax
1349       fmin fmod fpclass fpclassify hypot ilogb  int  isfinite  isgreater  is‐
1350       greaterequal  isinf  isinfinite  isless islessequal islessgreater isnan
1351       isnormal issubnormal isunordered iszero j0 j1 jn ldexp lgamma log log10
1352       log1p log2 logb nearbyint nextafter nexttoward pow remainder rint round
1353       scalb scalbn signbit sin sinh sqrt tan tanh tgamma trunc y0 y1 yn
1354
1355       In addition, arithmetic functions can be  defined  as  shell  functions
1356       with a variant of the function name syntax,
1357
1358       function .sh.math.name ident ... { list ;}
1359              where  name  is the function name used in the arithmetic expres‐
1360              sion and each identifier, ident is a name reference to the  long
1361              double   precision   floating  point  argument.   The  value  of
1362              .sh.value when the function returns is the value of  this  func‐
1363              tion.   User  defined  functions  can take up to 3 arguments and
1364              override C math library functions.
1365
1366       An internal representation of a variable as a double precision floating
1367       point can be specified with the -E [n], -F [n], or -X [n] option of the
1368       typeset special built-in command.  The -E option causes  the  expansion
1369       of the value to be represented using scientific notation when it is ex‐
1370       panded.  The optional option argument n defines the number of  signifi‐
1371       cant  figures.  The -F option causes the expansion to be represented as
1372       a floating decimal number when it is expanded.  The  -X  option  causes
1373       the  expansion  to  be  represented  using the %a format defined by ISO
1374       C-99.  The optional option argument n defines the number of places  af‐
1375       ter the decimal (or radix) point in this case.
1376
1377       An  internal integer representation of a variable can be specified with
1378       the -i [n] option of the typeset special  built-in  command.   The  op‐
1379       tional  option  argument n specifies an arithmetic base to be used when
1380       expanding the variable.  If you do not specify an arithmetic base, base
1381       10 will be used.
1382
1383       Arithmetic evaluation is performed on the value of each assignment to a
1384       variable with the -E, -F, -X, or -i attribute.   Assigning  a  floating
1385       point  number  to  a variable whose type is an integer causes the frac‐
1386       tional part to be truncated.
1387
1388   Prompting.
1389       When used interactively, the shell prompts with the value of PS1  after
1390       expanding  it for parameter expansion, command substitution, and arith‐
1391       metic expansion, before reading a command.  In addition, each single  !
1392       in  the prompt is replaced by the command number.  A !!  is required to
1393       place !  in the prompt.  If at any time a new-line is typed and further
1394       input is needed to complete a command, then the secondary prompt (i.e.,
1395       the value of PS2) is issued.
1396
1397   Conditional Expressions.
1398       A conditional expression is used with the [[ compound command  to  test
1399       attributes  of files and to compare strings.  Field splitting and path‐
1400       name expansion are not performed on the words between [[ and ]].   Each
1401       expression  can  be constructed from one or more of the following unary
1402       or binary expressions:
1403              string Same as -n string below.
1404              -a file
1405                     Same as -e below.  This is obsolete.
1406              -b file
1407                     True if file exists and is a block special file.
1408              -c file
1409                     True if file exists and is a character special file.
1410              -d file
1411                     True if file exists and is a directory.
1412              -e file
1413                     True if file exists.
1414              -f file
1415                     True if file exists and is an ordinary file.
1416              -g file
1417                     True if file exists and it has its setgid bit set.
1418              -k file
1419                     True if file exists and it has its sticky bit set.
1420              -n string
1421                     True if length of string is non-zero.
1422              -o ?option
1423                     True if option named option is a valid option name.
1424              -o option
1425                     True if option named option is on.
1426              -p file
1427                     True if file exists and is a fifo special file or a pipe.
1428              -r file
1429                     True if file exists and is readable by current process.
1430              -s file
1431                     True if file exists and has size greater than zero.
1432              -t fildes
1433                     True if file descriptor number fildes is open and associ‐
1434                     ated with a terminal device.
1435              -u file
1436                     True if file exists and it has its setuid bit set.
1437              -v name
1438                     True  if  variable  name  is a valid variable name and is
1439                     set.
1440              -w file
1441                     True if file exists and is writable by current process.
1442              -x file
1443                     True if file exists and is executable by current process.
1444                     If  file exists and is a directory, then true if the cur‐
1445                     rent process has permission to search in the directory.
1446              -z string
1447                     True if length of string is zero.
1448              -L file
1449                     True if file exists and is a symbolic link.
1450              -h file
1451                     True if file exists and is a symbolic link.
1452              -N file
1453                     True if file exists and the modification time is  greater
1454                     than the last access time.
1455              -O file
1456                     True if file exists and is owned by the effective user ID
1457                     of this process.
1458              -G file
1459                     True if file exists and its group matches  the  effective
1460                     group ID of this process.
1461              -R name
1462                     True if variable name is a name reference.
1463              -S file
1464                     True if file exists and is a socket.
1465              file1 -nt file2
1466                     True  if  file1  exists  and  file2 does not, or file1 is
1467                     newer than file2.
1468              file1 -ot file2
1469                     True if file2 exists and file1  does  not,  or  file1  is
1470                     older than file2.
1471              file1 -ef file2
1472                     True if file1 and file2 exist and refer to the same 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 value
1489                     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 set to the  empty  string  otherwise.
2235       Prepending ${.sh.editmode} to a value assigned to .sh.edchar will cause
2236       the 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 empty.
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                        empty, 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  first  non-blank  character.
2564                        Equivalent to ^i.
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  the  empty
2763              string  (specifying  the current directory).  Note that the cur‐
2764              rent directory may be specified by a dot (.)   or  by  an  empty
2765              path  name,  either  of  which  can appear immediately after the
2766              equal sign or between the colon delimiters anywhere else in  the
2767              path  list.   If arg begins with a / then the search path is not
2768              used.  Otherwise, each directory in the  path  is  searched  for
2769              arg.
2770              The  second form of cd substitutes the string new for the string
2771              old in the current directory name, PWD, and tries to  change  to
2772              this new directory.
2773              By default, symbolic link names are treated literally when find‐
2774              ing the directory name.  This is equivalent to  the  -L  option.
2775              The  -P  option causes symbolic links to be resolved when deter‐
2776              mining the directory.  The last instance of -L or -P on the com‐
2777              mand line determines which method is used.
2778              If -e and -P are both in effect and the correct PWD could not be
2779              determined after successfully changing the  directory,  cd  will
2780              return with exit status one and produce no output.  If any other
2781              error occurs while both flags are active,  the  exit  status  is
2782              greater than one.
2783              The cd command may not be executed by rksh.
2784
2785       command [ -pvxV ] name [ arg ... ]
2786              With the -v option, command is equivalent to the built-in whence
2787              command described below.  The -V option causes  command  to  act
2788              like whence -v.
2789
2790              Without the -v or -V options, command executes name with the ar‐
2791              guments given  by  arg.   Functions  and  aliases  will  not  be
2792              searched  for  when  finding  name.  If name refers to a special
2793              built-in, as marked with in this manual, command disables  the
2794              special  properties described above for that mark, executing the
2795              command as a regular built-in.  (For example, using command  set
2796              -o  option-name  prevents  a script from terminating when an in‐
2797              valid option name is given.)
2798
2799              The -p option causes the operating system's  standard  utilities
2800              path  (as output by getconf PATH) to be searched rather than the
2801              one defined by the value of PATH.
2802
2803              The -x option runs name as an external command, bypassing built-
2804              ins.  If the arguments contain at least one word that expands to
2805              multiple arguments, such as "$@" or *.txt, then  the  -x  option
2806              also allows executing external commands with argument lists that
2807              are longer than the operating system allows. This  functionality
2808              is similar to xargs(1) but is easier to use. The shell does this
2809              by invoking the external command multiple times if  needed,  di‐
2810              viding  the expanded argument list over the invocations. Any ar‐
2811              guments that come before the first word that expands to multiple
2812              arguments,  as  well  as any that follow the last such word, are
2813              considered static arguments and are repeated  for  each  invoca‐
2814              tion.  This  allows  each invocation to use the same command op‐
2815              tions, as well as the same trailing  destination  arguments  for
2816              commands  like  cp(1)  or  mv(1).  When all invocations are com‐
2817              pleted, command -x exits with the status of the invocation  that
2818              had  the  highest  exit status.  (Note that command -x may still
2819              fail with an "argument list too long" error if a single argument
2820              exceeds  the  maximum  length of the argument list, or if a long
2821              arguments list contains no word that expands to  multiple  argu‐
2822              ments.)
2823
2824compound vname[=value] ...
2825              Causes  each vname to be a compound variable.  The same as type‐
2826              set -C.
2827
2828continue [ n ]
2829              Resume the next iteration of the enclosing for, while, until, or
2830              select loop.  If n is specified, then resume at the n-th enclos‐
2831              ing loop.
2832
2833       disown [ job... ]
2834              Causes the shell not to send a HUP signal to each given job,  or
2835              all  active  jobs  if  job is omitted, when a login shell termi‐
2836              nates.
2837
2838       echo [ arg ... ]
2839              When the first arg does not begin with a -, and none of the  ar‐
2840              guments contain a \, then echo prints each of its arguments sep‐
2841              arated by a space and terminated by a new-line.  Otherwise,  the
2842              behavior  of  echo  is  system dependent and print or printf de‐
2843              scribed below should be used.  See echo(1)  for  usage  and  de‐
2844              scription.
2845
2846enum [ -i ] type[=(value ...) ] ...
2847              Creates,  for  each type specified, an enumeration type declara‐
2848              tion command named type.  Variables of the created type can only
2849              store   any   one  of  the  values  given.   For  example,  enum
2850              bool=(false true) creates a Boolean variable type of which vari‐
2851              ables may be declared like bool x=true y=false.  If =(value ...)
2852              is omitted, then type must be an indexed array variable with  at
2853              least  two  elements  and  the  values are taken from this array
2854              variable.  If -i is specified the values  are  case-insensitive.
2855              Declaration commands are created as special builtins that cannot
2856              be removed or overridden by shell functions.  Each created  dec‐
2857              laration  command has a --man option that shows documentation on
2858              its type's behavior and possible values.
2859
2860              Within arithmetic expressions (see Arithmetic Evaluation above),
2861              enumeration type values translate to index numbers between 0 and
2862              the number of defined values minus 1. It  is  an  error  for  an
2863              arithmetic  expression  to assign a value outside of that range.
2864              Decimal fractions are ignored.  Taking the bool  type  from  the
2865              example  above,  if a variable of this type is used in an arith‐
2866              metic expression, false translates to 0 and true to 1.  Enumera‐
2867              tion  values  may also be used directly in an arithmetic expres‐
2868              sion that refers to a variable of an enumeration type.  To  con‐
2869              tinue  our  example,  for  a bool variable v, ((v==true)) is the
2870              same as ((v==1)) and if a variable named true exists, it is  ig‐
2871              nored.
2872
2873eval [ arg ... ]
2874              The  arguments  are read as input to the shell and the resulting
2875              command(s) executed.
2876
2877exec [ -c ] [ -a name ] [ arg ... ]
2878              If arg is given, the command specified by the arguments is  exe‐
2879              cuted  in  place  of  this shell without creating a new process.
2880              The value of the SHLVL environment variable is decreased by one,
2881              unless  the  shell replaced is a subshell.  The -c option causes
2882              the environment to be cleared before applying  variable  assign‐
2883              ments associated with the exec invocation.  The -a option causes
2884              name rather than the first arg, to become argv[0]  for  the  new
2885              process.   If  arg  is  not  given and only I/O redirections are
2886              given, then this command persistently modifies file  descriptors
2887              as in redirect.
2888
2889exit [ n ]
2890              Causes  the  shell  to exit with the exit status specified by n.
2891              The value will be the least significant 8 bits of n  (if  speci‐
2892              fied)  or  of  the exit status of the last command executed.  An
2893              end-of-file will also cause the shell to exit, except for an in‐
2894              teractive shell that has the ignoreeof option turned on (see set
2895              below).
2896
2897       †‡ export [ -p ] [ name[=value] ] ...
2898              If name is not given, the names and values of each variable with
2899              the  export  attribute  are  printed with the values quoted in a
2900              manner that allows them to be re-input.  The export  command  is
2901              the  same  as  typeset -x except that if you use export within a
2902              function, no local variable is created.  The  -p  option  causes
2903              the  word export to be inserted before each one.  Otherwise, the
2904              given names are marked for automatic export to  the  environment
2905              of subsequently-executed commands.
2906
2907       false  Does nothing, and exits 1. Used with until for infinite loops.
2908
2909       fc [ -e ename  ] [ -N num ] [ -nlr ] [ first [ last ] ]
2910       fc -s  [ old=new ] [ command ]
2911              The same as hist.
2912
2913       fg [ job... ]
2914              This  command is only on systems that support job control.  Each
2915              job specified is brought to the foreground and waited for in the
2916              specified order.  Otherwise, the current job is brought into the
2917              foreground.  See Jobs for a description of the format of job.
2918
2919float vname[=value] ...
2920              Declares each vname to be a long  floating  point  number.   The
2921              same as typeset -lE.
2922
2923       functions [ -Stux ] [ name ... ]
2924              Lists functions.  The same as typeset -f.
2925
2926       getconf [ name [ pathname ] ]
2927              Prints the current value of the configuration parameter given by
2928              name.  The configuration parameters  are  defined  by  the  IEEE
2929              POSIX  1003.1 and IEEE POSIX 1003.2 standards.  (See pathconf(2)
2930              and sysconf(3).)  The pathname argument is required for  parame‐
2931              ters whose value depends on the location in the file system.  If
2932              no arguments are given, getconf prints the names and  values  of
2933              the  current  configuration  parameters.  The pathname / is used
2934              for each of the parameters that requires pathname.
2935
2936       getopts [ -a name ] optstring vname [ arg ... ]
2937              Checks arg for legal options.  If arg is omitted, the positional
2938              parameters are used.  An option argument begins with a + or a -.
2939              An option not beginning with + or - or the argument -- ends  the
2940              options.  Options beginning with + are only recognized when opt‐
2941              string begins with a +.  optstring  contains  the  letters  that
2942              getopts recognizes.  If a letter is followed by a :, that option
2943              is expected to have an argument.  The options can  be  separated
2944              from  the  argument by blanks.  The option -?  causes getopts to
2945              generate a usage message on standard error.  The -a argument can
2946              be  used to specify the name to use for the usage message, which
2947              defaults to $0.
2948              getopts places the next option letter it finds  inside  variable
2949              vname  each  time  it  is  invoked.   The  option letter will be
2950              prepended with a + when arg begins with a +.  The index  of  the
2951              next arg is stored in OPTIND.  The option argument, if any, gets
2952              stored in OPTARG.
2953              A leading : in optstring causes getopts to store the  letter  of
2954              an  invalid  option in OPTARG, and to set vname to ?  for an un‐
2955              known option and to : when a required option argument  is  miss‐
2956              ing.  Otherwise, getopts prints an error message.  The exit sta‐
2957              tus is non-zero when there are no more options.
2958              There is no way to specify any of the options :, +, -, ?, [, and
2959              ].  The option # can only be specified as the first option.
2960
2961       hash [ -r ] [ utility ]
2962              hash  displays  or modifies the hash table with the locations of
2963              recently used programs. If given no arguments, it lists all com‐
2964              mand/path  associations  (a.k.a.  'tracked aliases') in the hash
2965              table. Otherwise, hash performs a PATH search for  each  utility
2966              supplied  and  adds the result to the hash table.  The -r option
2967              empties the hash table. This can also be achieved  by  resetting
2968              PATH.
2969
2970       hist [ -e ename  ] [ -N num ] [ -nlr ] [ first [ last ] ]
2971       hist -s [ old=new ] [ command ]
2972              In the first form, a range of commands from first to last is se‐
2973              lected from the last HISTSIZE commands that were  typed  at  the
2974              terminal.   The  arguments  first and last may be specified as a
2975              number or as a string.  A string is used to locate the most  re‐
2976              cent  command starting with the given string.  A negative number
2977              is used as an offset to the current command number.  If  the  -l
2978              option  is selected, the commands are listed on standard output.
2979              Otherwise, the editor program ename is invoked on  a  file  con‐
2980              taining these keyboard commands.  If ename is not supplied, then
2981              the value of the variable HISTEDIT is used.  If HISTEDIT is  not
2982              set,  then FCEDIT (default /bin/ed) is used as the editor.  When
2983              editing is complete, the edited command(s) is  executed  if  the
2984              changes have been saved.  If last is not specified, then it will
2985              be set to first.  If first is not specified, the default is  the
2986              previous command for editing and -16 for listing.  The option -r
2987              reverses the order of the commands and the option -n  suppresses
2988              command  numbers  when  listing.  In the second form, command is
2989              interpreted as first described above and defaults  to  the  last
2990              command  executed.   The resulting command is executed after the
2991              optional substitution  old=new  is  performed.   The  option  -N
2992              causes hist to start num commands back.
2993
2994integer vname[=value] ...
2995              Declares  each  vname  to be a long integer number.  The same as
2996              typeset -li.
2997
2998       jobs [ -lnp ] [ job ... ]
2999              Lists information about each given job; or all  active  jobs  if
3000              job  is omitted.  The -l option lists process IDs in addition to
3001              the normal information.  The -n option only displays  jobs  that
3002              have  stopped  or  exited  since  last  notified.  The -p option
3003              causes only the process group to be listed.  See Jobs for a  de‐
3004              scription of the format of job.
3005
3006       kill [ -s signame ] job ...
3007       kill [ -n signum ] job ...
3008       kill -Ll [ sig ... ]
3009              Sends either the TERM (terminate) signal or the specified signal
3010              to the specified jobs or processes.  Signals are either given by
3011              number  with  the  -n  option  or by name with the -s option (as
3012              given in <signal.h>, stripped of the prefix ``SIG'' with the ex‐
3013              ception that SIGCLD is named CHLD).  For backward compatibility,
3014              the n and s can be omitted and the number or name placed immedi‐
3015              ately after the -.  If the signal being sent is TERM (terminate)
3016              or HUP (hangup), then the job or process will  be  sent  a  CONT
3017              (continue) signal if it is stopped.  The argument job can be the
3018              process ID of a process that is not a member of one of  the  ac‐
3019              tive jobs.  See Jobs for a description of the format of job.  In
3020              the third form, kill -l or kill -L, if sig is not specified, the
3021              signal  names  are  listed.  The -l option lists only the signal
3022              names.  The -L option lists each signal name  and  corresponding
3023              number.  Otherwise, for each sig that is a name, the correspond‐
3024              ing signal number is listed.  For each sig that is a number, the
3025              signal name corresponding to the least significant 8 bits of sig
3026              is listed.
3027
3028       let arg ...
3029              Each arg is a separate arithmetic expression  to  be  evaluated.
3030              let  only  recognizes octal numbers starting with 0 when the set
3031              option letoctal is on.  See Arithmetic Evaluation  above  for  a
3032              description of arithmetic expression evaluation.
3033              The exit status is 0 if the value of the last expression is non-
3034              zero, and 1 otherwise.
3035
3036nameref vname[=refname] ...
3037              Declares each vname to be a variable name reference.   The  same
3038              as typeset -n.
3039
3040       print [ -CRenprsv ] [ -u unit ] [ -f format ] [ arg ... ]
3041              With  no  options or with option - or --, each arg is printed on
3042              standard output.  The -f  option  causes  the  arguments  to  be
3043              printed  as  described  by printf.  In this case, any e, n, r, R
3044              options are ignored.  Otherwise, unless the -C, -R,  -r,  or  -v
3045              are specified, the following escape conventions will be applied:
3046              \a     The alert character (ASCII 07).
3047              \b     The backspace character (ASCII 010).
3048              \c     Causes print to end without processing more arguments and
3049                     not adding a new-line.
3050              \f     The formfeed character (ASCII 014).
3051              \n     The newline character (ASCII 012).
3052              \r     The carriage return character (ASCII 015).
3053              \t     The tab character (ASCII 011).
3054              \v     The vertical tab character (ASCII 013).
3055              \E     The escape character (ASCII 033).
3056              \\     The backslash character \.
3057              \0x    The character defined by  the  1,  2,  or  3-digit  octal
3058                     string given by x.
3059
3060              The  -R  option  will print all subsequent arguments and options
3061              other than -n.  The -e causes the above escape conventions to be
3062              applied.   This is the default behavior.  It reverses the effect
3063              of an earlier -r.  The -p option  causes  the  arguments  to  be
3064              written  onto the pipe of the process spawned with |& instead of
3065              standard output.  The -v option treats each arg  as  a  variable
3066              name  and  writes the value in the printf %B format.  The -C op‐
3067              tion treats each arg as a variable name and writes the value  in
3068              the printf %#B format.  The -s option causes the arguments to be
3069              written onto the history file instead of standard  output.   The
3070              -u  option  can  be  used to specify a one digit file descriptor
3071              unit number unit on which the output will be  placed.   The  de‐
3072              fault  is  1.  If the option -n is used, no new-line is added to
3073              the output.
3074
3075       printf [ -v vname ] format [ arg ... ]
3076              The arguments arg are printed on standard output  in  accordance
3077              with  the  ANSI  C  formatting  rules associated with the format
3078              string format.  If the number of arguments exceeds the number of
3079              format specifications, the format string is reused to format re‐
3080              maining arguments.  The following extensions can also be used:
3081              %b     A %b format can be used instead of %s to cause escape se‐
3082                     quences  in  the  corresponding arg to be expanded as de‐
3083                     scribed in print.
3084              %B     A %B option causes each of the arguments to be treated as
3085                     variable  names  and the binary value of variable will be
3086                     printed.  The alternate flag # causes a compound variable
3087                     to  be  output on a single line.  This is most useful for
3088                     compound variables and variables whose attribute is -b.
3089              %H     A %H format can be used instead of %s to cause characters
3090                     in  arg  that are special in HTML and XML to be output as
3091                     their entity name.  The alternate flag # formats the out‐
3092                     put for use as a URI.
3093              %p     A %p format will convert the given number to hexadecimal.
3094              %P     A  %P format can be used instead of %s to cause arg to be
3095                     interpreted as an  extended  regular  expression  and  be
3096                     printed as a shell pattern.
3097              %q     A  %q  format  can be used instead of %s to cause the re‐
3098                     sulting string to be quoted in a manner than can be rein‐
3099                     put  to the shell.  When q is preceded by the alternative
3100                     format specifier, #, the string is quoted in manner suit‐
3101                     able as a field in a .csv format file.
3102              %(date-format)T
3103                     A %(date-format)T format can be used to treat an argument
3104                     as a date/time string and to format the date/time accord‐
3105                     ing to the date-format.
3106              %Q     A  %Q  format will convert the given number of seconds to
3107                     readable time.
3108              %R     A %R format can be used instead of %s to cause arg to  be
3109                     interpreted  as  a  shell pattern and to be printed as an
3110                     extended regular expression.
3111              %Z     A %Z format will output a byte whose value is 0.
3112              %d     The precision field of the %d format can be followed by a
3113                     .  and the output base.  In this case, the # flag charac‐
3114                     ter causes base# to be prepended.
3115              #      The # flag, when used with the %d format without an  out‐
3116                     put base, displays the output in powers of 1000 indicated
3117                     by one of the following suffixes: k M G T P E,  and  when
3118                     used  with the %i format displays the output in powers of
3119                     1024 indicated by one of the following suffixes: Ki Mi Gi
3120                     Ti Pi Ei.
3121              =      The  = flag centers the output within the specified field
3122                     width.
3123              L      The L flag, when used with the %c or %s  formats,  treats
3124                     precision as character width instead of byte count.
3125              ,      The  ,  flag,  when used with the %d or %f formats, sepa‐
3126                     rates groups of digits with the grouping delimiter (,  on
3127                     groups of 3 in the C locale).
3128
3129              The  -v option assigns the output directly to a variable instead
3130              of writing it to standard output. This is faster than  capturing
3131              the  output using a command substitution and avoids the latter's
3132              stripping of final linefeed characters (\n). The vname  argument
3133              should be a valid variable name, optionally with one or more ar‐
3134              ray subscripts in square brackets.  Note  that  square  brackets
3135              should be quoted to avoid pathname expansion.
3136
3137
3138       pwd [ -LP ]
3139              Outputs  the value of the current working directory.  The -L op‐
3140              tion is the default; it prints the logical name of  the  current
3141              directory.   If  the  -P option is given, all symbolic links are
3142              resolved from the name.  The last instance of -L or  -P  on  the
3143              command line determines which method is used.
3144
3145       read  [  -ACSaprsv ] [ -d delim ] [ -n n ] [ -N n ] [ -t timeout ] [ -u
3146       unit ] [ vname?prompt ] [ vname ... ]
3147              The shell input mechanism.  One line is read and  is  broken  up
3148              into  fields using the characters in IFS as separators.  The es‐
3149              cape character, \, is used to remove any special meaning for the
3150              next  character  and  for line continuation.  The first field is
3151              assigned to the first vname, the  second  field  to  the  second
3152              vname,  etc.,  with  leftover fields assigned to the last vname.
3153              If vname is omitted, then REPLY is used as  the  default  vname.
3154              When  vname  has the binary attribute and -n or -N is specified,
3155              the bytes that are read are stored directly into  the  variable.
3156              If you append ?prompt to the first vname, then read will display
3157              prompt on standard error before reading if standard input  is  a
3158              terminal  or  pipe;  the  ?  should be quoted to protect it from
3159              pathname expansion.  The exit status is 0 unless an  end-of-file
3160              is  encountered or read has timed out.  The options for the read
3161              command have meaning as follows:
3162              -A      Causes the variable vname to be  unset  and  each  field
3163                      that  is read to be stored in successive elements of the
3164                      indexed array vname.
3165              -C      Causes the variable vname to be read as a compound vari‐
3166                      able.  Blanks will be ignored when finding the beginning
3167                      open parenthesis.
3168              -N      Causes n bytes to be read unless an end-of-file has been
3169                      encountered  or the read times out because of the -t op‐
3170                      tion.
3171              -S      Causes the line to be treated like a record  in  a  .csv
3172                      format  file  so that double quotes can be used to allow
3173                      the delimiter character and the  new-line  character  to
3174                      appear within a field.
3175              -a      Same as -A.
3176              -d      Causes  the  read  to continue to the first character of
3177                      delim instead of the newline control character.
3178              -n      Causes at most n bytes to be  read  instead  of  a  full
3179                      line, but will return when reading from a slow device as
3180                      soon as any characters have been read.
3181              -p      Input is read from the current co-process spawned by the
3182                      shell  using  ⎪&.  An end-of-file causes read to discon‐
3183                      nect the co-process so that another can be created.
3184              -r      Raw mode. The \ character is not treated specially.
3185              -s      The input will be saved as  a  command  in  the  history
3186                      file.
3187              -t      Used to specify a timeout in seconds when reading from a
3188                      terminal or pipe.
3189              -u      This option can be used to specify a one-digit file  de‐
3190                      scriptor  unit  unit  to read from.  The file descriptor
3191                      can be opened with the exec or  redirect  built-in  com‐
3192                      mand.   If unit is p, input is read from the current co-
3193                      process as with the -p option.   The  default  value  of
3194                      unit is 0.
3195              -v      The  value  of the first vname will be used as a default
3196                      value when reading from a terminal device.
3197
3198       †‡ readonly [ -p ] [ vname[=value] ] ...
3199              If vname is not given, the names and  values  of  each  variable
3200              with  the  read-only attribute is printed with the values quoted
3201              in a manner that allows them to  be  re-input.   The  -p  option
3202              causes the word readonly to be inserted before each one.  Other‐
3203              wise, the given vnames are marked read-only and these names can‐
3204              not  be  changed  by subsequent assignment.  Unlike typeset -r ,
3205              readonly does not create a function-local scope  and  the  given
3206              vnames  are marked globally read-only by default.  When defining
3207              a type, if the value of a read-only subvariable is not  defined,
3208              the value is required when creating each instance.
3209
3210       redirect
3211              This  command  only  accepts  input/output redirections.  It can
3212              open and close files and modify file descriptors from 0 to 9  as
3213              specified  by  the  input/output  redirection  list (see the In‐
3214              put/Output section above), with the difference that  the  effect
3215              persists  past  the execution of the redirect command.  When in‐
3216              voking another program, file descriptors  greater  than  2  that
3217              were  opened  with this mechanism are only passed on if they are
3218              explicitly redirected to themselves as part  of  the  invocation
3219              (e.g. 4>&4) or if the posix option is set.
3220
3221return [ n ]
3222              Causes  a shell function, dot script (see . and source), or pro‐
3223              file script to return to the invoking shell environment with the
3224              exit  status specified by n.  This status value can use the full
3225              signed integer range as shown by the  commands  getconf  INT_MIN
3226              and  getconf  INT_MAX. A value outside that range will produce a
3227              warning and an exit status of 128.  If n is  omitted,  then  the
3228              value  of  $? is assumed, i.e., the exit status of the last com‐
3229              mand executed is passed on.  If return is invoked while not in a
3230              function,  dot  script,  or  profile script, then it behaves the
3231              same as exit.
3232
3233set [ ±BCGHabefhkmnprstuvx ] [ ±o [ option ] ] ... [ ±A  vname  ]   [
3234       arg ... ]
3235              The options for this command have meaning as follows:
3236              -A      Array  assignment.   Unset the variable vname and assign
3237                      values sequentially from the arg list.  If +A  is  used,
3238                      the variable vname is not unset first.
3239              -B      Enable  brace  group expansion. On by default, except if
3240                      ksh is invoked as sh or rsh.
3241              -C      Prevents redirection > from truncating  existing  files.
3242                      Files  that are created are opened with the O_EXCL mode.
3243                      Requires >| to truncate a file when turned on.
3244              -G      Enables recursive pathname  expansion.   This  adds  the
3245                      double-star  pattern  **  to the pathname expansion (see
3246                      Pathname Expansion above).  By itself,  it  matches  the
3247                      recursive contents of the current directory, which is to
3248                      say, all files and directories in the current  directory
3249                      and  in  all its subdirectories, sub-subdirectories, and
3250                      so on.  If the pathname pattern ends in **/, only direc‐
3251                      tories  and  subdirectories  are matched, including sym‐
3252                      bolic links that point to directories.  A  prefixed  di‐
3253                      rectory  name is not included in the results unless that
3254                      directory was itself found by a  pattern.  For  example,
3255                      dir/** matches the recursive contents of dir but not dir
3256                      itself, whereas di[r]/** matches both dir itself and the
3257                      recursive contents of dir.  Symbolic links to non-direc‐
3258                      tories are not followed.  Symbolic links to  directories
3259                      are  followed if they are specified literally or match a
3260                      pattern as described under Pathname Expansion,  but  not
3261                      if they result from a double-star pattern.
3262              -H      Enable !-style history expansion similar to csh(1).  See
3263                      History Expansion above.
3264              -a      All variables that are assigned a value while  this  op‐
3265                      tion  is on are automatically exported, unless they have
3266                      a dot in their name.  Variables  created  in  namespaces
3267                      declared  with  the  namespace  keyword (see Name Spaces
3268                      above) are only exported while their name space  is  ac‐
3269                      tive.
3270              -b      Prints  job  completion messages as soon as a background
3271                      job changes state  rather  than  waiting  for  the  next
3272                      prompt.  If one of the shell line editors is in use (see
3273                      In-line Editing Options above), the  completion  message
3274                      is inserted directly above the command line being typed.
3275              -e      Unless  contained  in a || or && command, or the command
3276                      following an if while or until command or in  the  pipe‐
3277                      line  following !, if a command has a non-zero exit sta‐
3278                      tus, execute the ERR trap, if set, and exit.  This  mode
3279                      is disabled while reading profiles.
3280              -f      Disables pathname expansion.
3281              -h      Obsolete; no effect.
3282              -k      All  variable assignment arguments are placed in the en‐
3283                      vironment for a command, not just those that precede the
3284                      command name.
3285              -m      Background jobs will run in a separate process group and
3286                      a line will print upon completion.  The exit  status  of
3287                      background  jobs is reported in a completion message.  A
3288                      pipeline will not terminate until all component commands
3289                      of  the  pipeline  have terminated.  On systems with job
3290                      control, this option is turned on automatically for  in‐
3291                      teractive shells.
3292              -n      Read  commands  and check them for syntax errors, but do
3293                      not execute them.  Ignored for interactive shells.
3294              -o      The following argument can be one of the  following  op‐
3295                      tion names:
3296                      allexport
3297                              Same as -a.
3298                      backslashctrl
3299                              The  backslash character \ escapes the next con‐
3300                              trol character in the emacs built-in editor  and
3301                              the  next  erase  or  kill  character  in the vi
3302                              built-in editor.  On by default.
3303                      bgnice  All background jobs are run at a lower priority.
3304                              This is the default mode.
3305                      braceexpand
3306                              Same as -B.
3307                      emacs   Puts  you  in  an emacs style in-line editor for
3308                              command entry.
3309                      errexit Same as -e.
3310                      functrace
3311                              Causes the -x option's state and the DEBUG  trap
3312                              action  to be inherited by functions defined us‐
3313                              ing the function keyword (see  Functions  above)
3314                              instead of being reset to default.  Changes made
3315                              to them within the  function  do  not  propagate
3316                              back  to  the parent scope.  Similarly, this op‐
3317                              tion also causes the DEBUG trap action to be in‐
3318                              herited by subshells.
3319                      globcasedetect
3320                              When  this  option  is  turned on, globbing (see
3321                              Pathname Expansion above) and file name  listing
3322                              and  completion  (see  In-line  Editing  Options
3323                              above) automatically become case-insensitive  on
3324                              file systems where the difference between upper-
3325                              and lowercase is ignored for file names. This is
3326                              transparently  determined for each directory, so
3327                              a path pattern that spans multiple file  systems
3328                              can  be part case-sensitive and part case-insen‐
3329                              sitive.  In more precise terms, each slash-sepa‐
3330                              rated  path  name component pattern p is treated
3331                              as ~(i:p) if its parent directory  exists  on  a
3332                              case-insensitive  file  system.   This option is
3333                              only present on operating systems  that  support
3334                              case-insensitive file systems.
3335                      globstar
3336                              Same as -G.
3337                      gmacs   Puts  you  in  a  gmacs style in-line editor for
3338                              command entry.
3339                      histexpand
3340                              Same as -H.
3341                      histreedit
3342                              If a history expansion (see -H) fails, the  com‐
3343                              mand  line  is  reloaded  into the next prompt's
3344                              edit buffer, allowing corrections.
3345                      histverify
3346                              The results of a history expansion (see -H)  are
3347                              not immediately executed.  Instead, the expanded
3348                              line is loaded into the next prompt's edit  buf‐
3349                              fer, allowing further changes.
3350                      ignoreeof
3351                              An  interactive  shell  will not exit on end-of-
3352                              file.  The command exit must be used.
3353                      keyword Same as -k.
3354                      letoctal
3355                              The let command allows  octal  numbers  starting
3356                              with  0.   On by default if ksh is invoked as sh
3357                              or rsh.
3358                      markdirs
3359                              All directory names resulting from pathname  ex‐
3360                              pansion have a trailing / appended.
3361                      monitor Same as -m.
3362                      multiline
3363                              The  built-in editors will use multiple lines on
3364                              the screen for lines that are  longer  than  the
3365                              width  of the screen.  This may not work for all
3366                              terminals.
3367                      noclobber
3368                              Same as -C.
3369                      noexec  Same as -n.
3370                      noglob  Same as -f.
3371                      nolog   Obsolete; has no effect.
3372                      notify  Same as -b.
3373                      nounset Same as -u.
3374                      pipefail
3375                              The exit status of the entire pipeline  will  be
3376                              that  of  the last component command that exited
3377                              with a non-zero exit status, or zero if no  com‐
3378                              mand  exited  with  a non-zero exit status.  The
3379                              shell will wait for all  component  commands  of
3380                              the pipeline to terminate, instead of only wait‐
3381                              ing for the last component command.
3382                      posix   Enables the POSIX standard mode for maximum com‐
3383                              patibility  with  other compliant shells. At the
3384                              moment that the posix option is  turned  on,  it
3385                              also turns on letoctal and turns off -B/braceex‐
3386                              pand; the reverse is done when posix  is  turned
3387                              back off. (These options can still be controlled
3388                              independently  in  between.)  Furthermore,   the
3389                              posix option is automatically turned on upon in‐
3390                              vocation if the shell is invoked as sh  or  rsh,
3391                              or  if  -o  posix or --posix is specified on the
3392                              shell invocation command line, or when executing
3393                              scripts  without  a #! path with this option ac‐
3394                              tive in the invoking shell. In  that  case,  the
3395                              invoked  shell  will  not import type attributes
3396                              for variables (such  as  integer  or  left/right
3397                              justify) from the environment.
3398                              In addition, while on, the posix option
3399                              •  disables  exporting  variable type attributes
3400                                 to the environment for other ksh processes to
3401                                 import;
3402                              •  if  the  -B/braceexpand option is turned back
3403                                 on, disallows brace expansion on the  results
3404                                 of unquoted expansions;
3405                              •  disables  the  special  handling  of repeated
3406                                 isspace class characters in the IFS variable;
3407                              •  causes file descriptors > 2 to be  left  open
3408                                 when invoking another program;
3409                              •  disables the &> redirection shorthand;
3410                              •  disables  fast  filescan  loops of type while
3411                                 inputredirection ;do list ;done;
3412                              •  makes the <> redirection operator default  to
3413                                 redirecting  standard  input  if  no file de‐
3414                                 scriptor number precedes it;
3415                              •  causes the  shell  to  use  a  standard  UNIX
3416                                 pipe(2) instead of a socketpair(2) to connect
3417                                 commands in a pipeline (when reading directly
3418                                 from a pipeline, the <#pattern and <##pattern
3419                                 redirection operators will not work  and  the
3420                                 -n  option  to the read built-in will not re‐
3421                                 turn early when reading from a slow device);
3422                              •  disables the special floating point constants
3423                                 Inf and NaN in arithmetic evaluation so that,
3424                                 e.g., $((inf))  and  $((nan))  refer  to  the
3425                                 variables by those names;
3426                              •  enables  the recognition of a leading zero as
3427                                 introducing an octal number in all arithmetic
3428                                 evaluation contexts, except in the let built-
3429                                 in while letoctal is off;
3430                              •  disables zero-padding of seconds in the  out‐
3431                                 put of the time and times built-ins;
3432                              •  stops  the  .  command  (but not source) from
3433                                 looking up functions defined with  the  func‐
3434                                 tion syntax;
3435                              •  disables  the recognition of unexpanded shell
3436                                 arithmetic expressions in the numerical  com‐
3437                                 parison operators -eq, -ne, -gt, -ge, -lt and
3438                                 -le of the test/[ built-in  command,  causing
3439                                 them  to accept only decimal numbers as oper‐
3440                                 ands;
3441                              •  changes the test/[ built-in command  to  make
3442                                 its  deprecated  expr1  -a expr2 and expr1 -o
3443                                 expr2 operators work even if expr1 equals "!"
3444                                 or  "(" (which means the nonstandard unary -a
3445                                 file and -o option operators  cannot  be  di‐
3446                                 rectly  negated  using ! or wrapped in paren‐
3447                                 theses); and
3448                              •  disables a hack that makes test -t ([  -t  ])
3449                                 equivalent to test -t 1 ([ -t 1 ]).
3450                      privileged
3451                              Same as -p.
3452                      showme  When  enabled, simple commands or pipelines pre‐
3453                              ceded by a semicolon (;) will be displayed as if
3454                              the  xtrace  option were enabled but will not be
3455                              executed.  Otherwise, the leading ; will be  ig‐
3456                              nored.
3457                      trackall
3458                              Same as -h.
3459                      verbose Same as -v.
3460                      vi      Puts  you  in  insert mode of a vi style in-line
3461                              editor until you hit the escape  character  033.
3462                              This  puts  you in control mode.  A return sends
3463                              the line.
3464                      viraw   Each character is processed as it is typed in vi
3465                              mode.  The shell may have been compiled to force
3466                              this option on at all times.  Otherwise, canoni‐
3467                              cal processing (line-by-line input) is initially
3468                              enabled and the  command  line  will  be  echoed
3469                              again  if  the speed is 1200 baud or greater and
3470                              it contains any control characters or less  than
3471                              one  second  has  elapsed  since  the prompt was
3472                              printed. The ESC character terminates  canonical
3473                              processing  for the remainder of the command and
3474                              the user can then modify the command line.  This
3475                              scheme  has the advantages of canonical process‐
3476                              ing with the type-ahead echoing of raw mode.  If
3477                              the  viraw  option is set, the terminal will al‐
3478                              ways have canonical processing  disabled.   This
3479                              mode is implicit for systems that do not support
3480                              two alternate end of line delimiters, and may be
3481                              helpful for certain terminals.
3482                      xtrace  Same as -x.
3483
3484                      If  no  option name is supplied, then the current option
3485                      settings are printed.
3486
3487              -p      Disables processing of the $HOME/.profile file and  uses
3488                      the  file  /etc/suid_profile  instead  of  the ENV file.
3489                      This mode is on whenever the effective UID (GID) is  not
3490                      equal  to  the  real UID (GID).  Turning this off causes
3491                      the effective UID and GID to be set to the real UID  and
3492                      GID.
3493              -r      Enables the restricted shell.  This option cannot be un‐
3494                      set once set.
3495              -s      Sort the positional parameters lexicographically.
3496              -t      (Obsolete).  Exit after reading and executing  one  com‐
3497                      mand.
3498              -u      Treat  unset  parameters  as an error when substituting.
3499                      $@ and $* are exempt.
3500              -v      Print shell input lines as they are read.
3501              -x      Print commands and their arguments as they are executed.
3502              --      Do not change any of the options; useful in  setting  $1
3503                      to  a  value  beginning  with -.  If no arguments follow
3504                      this option then the positional parameters are unset.
3505
3506              As an obsolete feature, if the first arg is - then the -x and -v
3507              options  are turned off and the next arg is treated as the first
3508              argument.  Using + rather than -  causes  these  options  to  be
3509              turned  off.   These options can also be used upon invocation of
3510              the shell.  The current set of options may be found in $-.   Un‐
3511              less -A is specified, the remaining arguments are positional pa‐
3512              rameters and are assigned, in order, to $1 $2 ....  If no  argu‐
3513              ments  are given, then the names and values of all variables are
3514              printed on the standard output.
3515
3516shift [ n ]
3517              The positional parameters from $n+1 ...  are renamed  $1  ...  ,
3518              default  n  is 1.  The parameter n can be any arithmetic expres‐
3519              sion that evaluates to a non-negative number less than or  equal
3520              to $#.
3521
3522       sleep [ -s ] duration
3523              Suspends  execution  for  the number of decimal seconds or frac‐
3524              tions of a second given by duration.  duration can be  an  inte‐
3525              ger,  floating  point  value or ISO 8601 duration specifying the
3526              length of time to sleep.  The option -s causes the sleep builtin
3527              to  terminate  when  it receives any signal.  If duration is not
3528              specified in conjunction with -s, sleep will wait for  a  signal
3529              indefinitely.
3530
3531       source name [ arg ... ]
3532              Same  as  ., except it is not treated as a special built-in com‐
3533              mand.
3534
3535       stop job ...
3536              Sends a SIGSTOP signal to one or  more  processes  specified  by
3537              job,  suspending  them  until they receive SIGCONT.  The same as
3538              kill -s STOP.
3539
3540       suspend
3541              Sends a SIGSTOP signal to the main shell process, suspending the
3542              script or child shell session until it receives SIGCONT (for in‐
3543              stance, when typing fg  in  the  parent  shell).  Equivalent  to
3544              kill -s STOP "$$",  except  that  it accepts no operands and re‐
3545              fuses to suspend a login shell.
3546
3547       test expression
3548              The test and [ commands execute conditional expressions  similar
3549              to those specified for the [[ compound command under Conditional
3550              Expressions above, but with several important  differences.  The
3551              =, == and != operators test for string (in)equality without pat‐
3552              tern matching; == is nonstandard and unportable. The &&  and  ||
3553              operators are not available. Instead, the -a and -o binary oper‐
3554              ators can be used, but they are fraught  with  pitfalls  due  to
3555              grammatical ambiguities and therefore deprecated in favor of in‐
3556              voking separate test commands. Most importantly, as test  and  [
3557              are simple regular commands, field splitting and pathname expan‐
3558              sion are performed on all their arguments  and  all  aspects  of
3559              regular  shell grammar (such as redirection) remain active. This
3560              is usually harmful, so care must be taken to quote arguments and
3561              expansions  to  avoid  this.  To avoid the many pitfalls arising
3562              from these issues, the [[ compound command should  be  used  in‐
3563              stead. The primary purpose of the test and [ commands is compat‐
3564              ibility with other shells that lack [[.
3565
3566              The test/[ command does not parse options except  if  there  are
3567              two  arguments  and the second is --. To access the inline docu‐
3568              mentation with an option such as --man,  you  need  one  of  the
3569              forms test --man -- or [ --man -- ].
3570
3571       times  Displays  the  accumulated  user  and system CPU times, one line
3572              with the times used by the shell and another with those used  by
3573              all  of  the  shell's child processes. No options are supported.
3574              Seconds are zero-padded unless the posix shell option is on.
3575
3576trap [ -p ] [ action ] [ sig ] ...
3577              The -p option causes the trap action associated with  each  trap
3578              as  specified  by  the  arguments to be printed with appropriate
3579              quoting.  Otherwise, action will be processed as if it  were  an
3580              argument  to  eval  when the shell receives signal(s) sig.  Each
3581              sig can be given as a number or as the name of the signal.  Trap
3582              commands are executed in order of signal number.  Any attempt to
3583              set a trap on a signal that was ignored on entry to the  current
3584              shell is ineffective.  If action is omitted and the first sig is
3585              a number, or if action is -, then the trap(s) for each  sig  are
3586              reset  to their original values.  If action is the empty string,
3587              then this signal is ignored by the shell and by the commands  it
3588              invokes.   If sig is ERR then action will be executed whenever a
3589              command has a non-zero exit status.  If sig is DEBUG then action
3590              will  be executed before each command.  The variable .sh.command
3591              will contain the current command line when action is running, in
3592              the  same  format  as  the output generated by the xtrace option
3593              (minus the preceding PS4 prompt).  If the  exit  status  of  the
3594              trap  is 2 the command will not be executed.  If the exit status
3595              of the trap is 255 and inside a function or a  dot  script,  the
3596              function or dot script will return.  If sig is 0 or EXIT and the
3597              trap statement is executed inside the body of a function defined
3598              with  the  function name syntax, then the command action is exe‐
3599              cuted after the function completes.  If sig is 0 or EXIT  for  a
3600              trap  set  outside  any function then the command action is exe‐
3601              cuted on exit from the shell.  If sig is KEYBD, then action will
3602              be  executed whenever a key is read while in emacs, gmacs, or vi
3603              mode.  The trap command with no arguments prints a list of  com‐
3604              mands associated with each signal number.
3605
3606       An  exit  or  return without an argument in a trap action will preserve
3607       the exit status of the command that invoked the trap.
3608
3609       true   Does nothing, and exits 0. Used with while for infinite loops.
3610
3611       type [ -afpPqt ] name ...
3612              The same as whence -v.
3613
3614       †‡ typeset [ ±ACHSbflmnprstux ] [ ±EFLRXZi[n] ]   [ +-M  [ mapname ]  ]
3615       [ -T  [ tname=(assign_list) ] ] [ -h str ] [ -a [type] ] [ vname[=value
3616       ]  ] ...
3617              Sets attributes and values for shell  variables  and  functions.
3618              When  invoked  inside  a function defined with the function name
3619              syntax, a new instance of the variable vname is created, and the
3620              variable's  value  and  type are restored when the function com‐
3621              pletes.  The following list of attributes may be specified:
3622              -A     Declares vname to be an  associative  array.   Subscripts
3623                     are strings rather than arithmetic expressions.
3624              -C     Causes  each  vname  to  be a compound variable. If value
3625                     names a compound variable, it is copied into vname.  Oth‐
3626                     erwise, the empty compound value is assigned to vname.
3627              -a     Declares vname to be an indexed array.  If type is speci‐
3628                     fied, it must be the name of an enumeration type  created
3629                     with the enum command and it allows enumeration constants
3630                     to be used as subscripts.
3631              -E     Declares vname to be a double  precision  floating  point
3632                     number.   If n is non-zero, it defines the number of sig‐
3633                     nificant figures that  are  used  when  expanding  vname.
3634                     Otherwise, ten significant figures will be used.
3635              -F     Declares  vname  to  be a double precision floating point
3636                     number.  If n is  non-zero,  it  defines  the  number  of
3637                     places after the decimal point that are used when expand‐
3638                     ing vname.  Otherwise ten places after the decimal  point
3639                     will be used.
3640              -H     This  option  provides  UNIX to host-name file mapping on
3641                     non-UNIX machines.
3642              -L     Left justify and remove leading blanks from value.  If  n
3643                     is non-zero, it defines the width of the field, otherwise
3644                     it is determined by the width of the value of  first  as‐
3645                     signment.  When the variable is assigned to, it is filled
3646                     on the right with blanks or truncated, if  necessary,  to
3647                     fit into the field.  The -R option is turned off.
3648              -M     Use  the character mapping mapping defined by wctrans(3).
3649                     such as tolower and toupper when  assigning  a  value  to
3650                     each  of  the specified operands.  When mapping is speci‐
3651                     fied and there are not operands, all variables  that  use
3652                     this  mapping  are written to standard output.  When map‐
3653                     ping is omitted and there are  no  operands,  all  mapped
3654                     variables are written to standard output.
3655              -R     Right justify and fill with leading blanks.  If n is non-
3656                     zero, it defines the width of the field, otherwise it  is
3657                     determined by the width of the value of first assignment.
3658                     The field is left filled with blanks  or  truncated  from
3659                     the  end if the variable is reassigned.  The -L option is
3660                     turned off.
3661              -S     When used within the assign_list of a type definition, it
3662                     causes  the specified subvariable to be shared by all in‐
3663                     stances of the type.  When used inside a function defined
3664                     with  the function reserved word, the specified variables
3665                     will have function static scope.  Otherwise, the variable
3666                     is unset prior to processing the assignment list.
3667              -T     If  followed  by  tname, it creates a type named by tname
3668                     using the compound assignment assign_list to tname.  Oth‐
3669                     erwise,  it  writes  all the type definitions to standard
3670                     output.
3671              -X     Declares vname to be a double  precision  floating  point
3672                     number  and expands using the %a format of ISO-C99.  If n
3673                     is non-zero, it defines the number of  hex  digits  after
3674                     the  radix  point that is used when expanding vname.  The
3675                     default is 10.
3676              -Z     Right justify and fill with leading zeros  if  the  first
3677                     non-blank  character is a digit and the -L option has not
3678                     been set.  Remove leading zeros if the -L option is  also
3679                     set.   If  n  is  non-zero,  it  defines the width of the
3680                     field, otherwise it is determined by  the  width  of  the
3681                     value of first assignment.
3682              -f     The  names  refer  to function names rather than variable
3683                     names.  No assignments can be made  and  the  only  other
3684                     valid  options are -S, -t, -u and -x.  The -S can be used
3685                     with discipline functions defined in a type  to  indicate
3686                     that  the function is static.  For a static function, the
3687                     same method will be used by all instances of that type no
3688                     matter which instance references it.  In addition, it can
3689                     only use value of variables from the original type  defi‐
3690                     nition.   These  discipline functions cannot be redefined
3691                     in any type instance.  The -t option turns  on  execution
3692                     tracing  for  this  function.   The -u option causes this
3693                     function to be marked undefined.  The FPATH variable will
3694                     be  searched  to  find  the  function definition when the
3695                     function is referenced.  If no options other than  -f  is
3696                     specified, then the function definition will be displayed
3697                     on standard output.  If +f is specified, then a line con‐
3698                     taining  the  function  name  followed by a shell comment
3699                     containing the line number and  path  name  of  the  file
3700                     where  this  function  was defined, if any, is displayed.
3701                     The exit status can be  used  to  determine  whether  the
3702                     function is defined so that typeset -f .sh.math.name will
3703                     return 0 when math function name is defined and  non-zero
3704                     otherwise.
3705              -b     The  variable  can hold any number of bytes of data.  The
3706                     data can be text or binary.  The value is represented  by
3707                     the  base64  encoding  of the data.  If -Z is also speci‐
3708                     fied, the size in bytes of the data in the buffer will be
3709                     determined  by  the  size associated with the -Z.  If the
3710                     base64 string assigned results in more data, it  will  be
3711                     truncated.  Otherwise, it will be filled with bytes whose
3712                     value is zero.  The printf format %B can be used to  out‐
3713                     put  the actual data in this buffer instead of the base64
3714                     encoding of the data.
3715              -g     Forces variables to be created or modified at the  global
3716                     scope,  even  when  typeset is executed in a function de‐
3717                     fined by the function name syntax (see  Functions  above)
3718                     or in a name space (see Name Spaces above).
3719              -h     Used within type definitions to add information when gen‐
3720                     erating information about  the  subvariable  on  the  man
3721                     page.   It is ignored when used outside of a type defini‐
3722                     tion.  When used with -f the  information  is  associated
3723                     with the corresponding discipline function.
3724              -i     Declares  vname  to be represented internally as integer.
3725                     The right hand side of an assignment is evaluated  as  an
3726                     arithmetic expression when assigning to an integer.  If n
3727                     is non-zero, it defines the output arithmetic base,  oth‐
3728                     erwise the output base will be ten.
3729              -l     Used with -i, -E or -F, to indicate long integer, or long
3730                     float.  Otherwise, all uppercase characters are converted
3731                     to  lowercase.   The uppercase option, -u, is turned off.
3732                     Equivalent to -M tolower .
3733              -m     Moves or renames the variable.  The value is the name  of
3734                     a variable whose value will be moved to vname.  The orig‐
3735                     inal variable will be unset.  Cannot  be  used  with  any
3736                     other options.
3737              -n     Declares  vname  to  be a reference to the variable whose
3738                     name is defined by the value of variable vname.  This  is
3739                     usually  used  to  reference a variable inside a function
3740                     whose name has been passed as  an  argument.   Cannot  be
3741                     used with other options except -g.
3742              -p     The  name, attributes and values for the given vnames are
3743                     written on standard output in a form that can be used  as
3744                     shell input.  If +p is specified, then the values are not
3745                     displayed.
3746              -r     The given vnames are marked  read-only  and  these  names
3747                     cannot be changed by subsequent assignment.
3748              -s     When  given  along  with  -i,  restricts  integer size to
3749                     short.
3750              -t     Tags the variables.  Tags are user definable and have  no
3751                     special meaning to the shell.
3752              -u     When  given  along  with  -i, specifies unsigned integer.
3753                     Otherwise, all lowercase characters are converted to  up‐
3754                     percase.   The  lowercase  option,  -l,  is  turned  off.
3755                     Equivalent to -M toupper .
3756              -x     The given vnames are marked for automatic export  to  the
3757                     environment of subsequently-executed commands.  Variables
3758                     whose names contain a .  cannot be exported.
3759
3760              The -i, -F, -E, and -X options cannot be  specified  along  with
3761              -R, -L, or -Z.  The -b option cannot be specified along with -L,
3762              -u, or -l.  The -f, -m, -n, and -T options cannot  be  used  to‐
3763              gether with any other option.
3764
3765              Using + rather than - causes these options to be turned off.  If
3766              no vname arguments are given, a list of vnames  (and  optionally
3767              the values) of the variables is printed.  (Using + rather than -
3768              keeps the values from being  printed.)   The  -p  option  causes
3769              typeset followed by the option letters to be printed before each
3770              name rather than the names of the options.  If any option  other
3771              than  -p  is  given,  only those variables which have all of the
3772              given options are printed.  Otherwise, the vnames and attributes
3773              of all variables that have attributes are printed.
3774
3775       ulimit [ -HSaMctdfkxlqenVuPpmrRbiswTv ] [ limit ]
3776              Set  or display a resource limit.  The available resource limits
3777              are listed below.  Many systems do not support one  or  more  of
3778              these  limits.   The  limit for a specified resource is set when
3779              limit is specified.  The value of limit can be a number  in  the
3780              unit specified below with each resource, or the value unlimited.
3781              The -H and -S options specify whether the hard limit or the soft
3782              limit for the given resource is set.  A hard limit cannot be in‐
3783              creased once it is set.  A soft limit can be increased up to the
3784              value of the hard limit.  If neither the H nor S option is spec‐
3785              ified, the limit applies to both.  The current resource limit is
3786              printed  when limit is omitted.  In this case, the soft limit is
3787              printed unless H is specified.  When more than one  resource  is
3788              specified,  then  the  limit name and unit is printed before the
3789              value.
3790              -a     Lists all of the current resource limits.
3791              -b     The socket buffer size in bytes.
3792              -c     The number of 512-byte blocks on the size of core dumps.
3793              -d     The number of K-bytes on the size of the data area.
3794              -e     The scheduling priority.
3795              -f     The number of 512-byte blocks on files that can be  writ‐
3796                     ten  by  the current process or by child processes (files
3797                     of any size may be read).
3798              -i     The signal queue size.
3799              -k     The max number of kqueues created by the current user.
3800              -l     The locked address space in K-bytes.
3801              -M     The address space limit in K-bytes.
3802              -m     The number of K-bytes on the size of physical memory.
3803              -n     The number of file descriptors plus 1.
3804              -P     The max number of pseudo-terminals created by the current
3805                     user.
3806              -p     The number of 512-byte blocks for pipe buffering.
3807              -q     The message queue size in K-bytes.
3808              -R     The max time a real-time process can run before blocking,
3809                     in microseconds.  If this limit is exceeded  the  process
3810                     is sent a SIGXCPU signal.
3811              -r     The max real-time priority.
3812              -s     The number of K-bytes on the size of the stack area.
3813              -T     The number of threads.
3814              -t     The number of CPU seconds to be used by each process.
3815              -u     The number of processes.
3816              -V     The number of open vnode monitors.
3817              -v     The number of K-bytes for virtual memory.
3818              -w     The swap size in K-bytes.
3819              -x     The number of file locks.
3820
3821              If no option is given, -f is assumed.
3822
3823       umask [ -S ] [ mask ]
3824              The user file-creation mask is set to mask (see umask(2)).  mask
3825              can either be an octal number or a symbolic value  as  described
3826              in  chmod(1).  If a symbolic value is given, the new umask value
3827              is the complement of the result of applying mask to the  comple‐
3828              ment  of the previous umask value.  If mask is omitted, the cur‐
3829              rent value of the mask is printed.  The  -S  option  causes  the
3830              mode  to be printed as a symbolic value.  Otherwise, the mask is
3831              printed in octal.
3832
3833       unalias [ -a ] name ...
3834              The aliases given by the list of  names  are  removed  from  the
3835              alias list.  The -a option causes all the aliases to be unset.
3836
3837unset [ -fnv ] vname ...
3838              The  variables given by the list of vnames are unassigned, i.e.,
3839              except for subvariables within a  type,  their  values  and  at‐
3840              tributes are erased.  For subvariables of a type, the values are
3841              reset to the default value from the type  definition.   Readonly
3842              variables  cannot  be  unset.  If the -f option is set, then the
3843              names refer to function names.  If the -v option  is  set,  then
3844              the  names refer to variable names.  The -f option overrides -v.
3845              If -n is set and name is a name reference, then name will be un‐
3846              set rather than the variable that it references.  The default is
3847              equivalent to -v.  Unsetting LINENO, MAILCHECK, OPTARG,  OPTIND,
3848              RANDOM, SECONDS, TMOUT, and _ removes their special meaning even
3849              if they are subsequently assigned to.
3850
3851       wait [ job ... ]
3852              Wait for the specified job and report  its  termination  status.
3853              If  job  is not given, then all currently active child processes
3854              are waited for.  The exit status from this command  is  that  of
3855              the last process waited for if job is specified; otherwise it is
3856              zero.  See Jobs for a description of the format of job.
3857
3858       whence [ -afpPqtv ] name ...
3859              For each name, indicate how it would be interpreted if used as a
3860              command name.
3861              The  -v  option  produces  a more verbose report.  The -f option
3862              skips the search for functions.  The -p and -P options do a path
3863              search  for  name even if name is an alias, a function, or a re‐
3864              served word.  Both of these options turn off the -v option.  The
3865              -q option causes whence to enter quiet mode.  whence will return
3866              zero if all arguments are built-ins, functions, or are  programs
3867              found  on  the path.  The -t option only outputs the type of the
3868              given command.  Like -p and -P, -t will turn off the -v  option.
3869              The  -a option is similar to the -v option but causes all inter‐
3870              pretations of the given name to be reported.
3871
3872   Invocation.
3873       If the shell is invoked by exec(2), initialization depends on  argument
3874       zero ($0) as follows.  If the first character of $0 is -, or the -l op‐
3875       tion is given on the invocation command line, then the shell is assumed
3876       to be a login shell.  If the basename of the command path in $0 is rsh,
3877       rksh, or krsh, then the shell becomes restricted.  If the  basename  is
3878       sh  or  rsh,  or the -o posix option is given on the invocation command
3879       line, then the shell is initialized in full POSIX compliance mode  (see
3880       the  set  builtin  command above for more information).  After this, if
3881       the shell was assumed to be a  login  shell,  commands  are  read  from
3882       /etc/profile and then from $HOME/.profile if it exists.  Alternatively,
3883       the option -l causes the shell to be treated as a login  shell.   Next,
3884       for interactive shells, commands are read from the file named by ENV if
3885       the file exists, its name being determined by performing parameter  ex‐
3886       pansion, command substitution, and arithmetic expansion on the value of
3887       that environment variable.  If the -s option is not present and arg and
3888       a  file  by  the  name  of  arg exists, then it reads and executes this
3889       script.  Otherwise, if the first arg does  not  contain  a  /,  a  path
3890       search  is  performed  on  the  first  arg to determine the name of the
3891       script to execute.  The script arg must have execute permission and any
3892       setuid and setgid settings will be ignored.  If the script is not found
3893       on the path, arg is processed as if it  named  a  built-in  command  or
3894       function.  Commands are then read as described below; the following op‐
3895       tions are interpreted by the shell when it is invoked:
3896
3897       -D      A list of all double quoted strings that are preceded  by  a  $
3898               will  be  printed  on  standard output and the shell will exit.
3899               This set of strings will be  subject  to  language  translation
3900               when  the  locale  is not C or POSIX.  No commands will be exe‐
3901               cuted.
3902
3903       -E or -o rc or --rc
3904               Read the file named by the ENV variable or by  $HOME/.kshrc  if
3905               not  defined after the profiles.  On by default for interactive
3906               shells. Use +E, +o rc or --norc to turn off.
3907
3908       -c      Read and execute a script from the first arg instead of a file.
3909               The  second arg, if present, becomes that script's command name
3910               ($0).  Any third and further args become positional  parameters
3911               starting at $1.
3912
3913       -s      Read  and  execute  a  script  from standard input instead of a
3914               file.  The command name ($0) cannot be set.   Any  args  become
3915               the  positional  parameters  starting  at  $1.   This option is
3916               forced on if no arg is given and is ignored if -c is also spec‐
3917               ified.
3918
3919       -i or -o interactive or --interactive
3920               If  the  -i  option is present or if the shell's standard input
3921               and standard error are attached to a terminal (as told by tcge‐
3922               tattr(3)),  then  this shell is interactive.  In this case TERM
3923               is ignored (so that kill 0 does not kill an interactive  shell)
3924               and INTR is caught and ignored (so that wait is interruptible).
3925               In all cases, QUIT is ignored by the shell.
3926
3927       -r or -o restricted or --restricted
3928               If the -r option is present, the shell is a restricted shell.
3929
3930       The remaining options and arguments are described under the set command
3931       above.  An optional - as the first argument is ignored.
3932
3933   Rksh Only.
3934       Rksh is used to set up login names and execution environments whose ca‐
3935       pabilities are more controlled than those of the standard  shell.   The
3936       actions  of rksh are identical to those of ksh, except that the follow‐
3937       ing are disallowed:
3938
3939              •      unsetting the restricted option
3940
3941              •      changing directory (see cd(1))
3942
3943              •      setting or unsetting the value or  attributes  of  SHELL,
3944                     ENV, FPATH, or PATH
3945
3946              •      specifying path or command names containing /
3947
3948              •      redirecting output (>, >|, <>, and >>)
3949
3950              •      adding or deleting built-in commands
3951
3952              •      using command -p to invoke a command
3953
3954       The  restrictions  above  are enforced after .profile and the ENV files
3955       are interpreted.
3956
3957       When a command to be executed is found to be a  shell  procedure,  rksh
3958       invokes ksh to execute it.  Thus, it is possible to provide to the end-
3959       user shell procedures that have access to the full power of  the  stan‐
3960       dard  shell, while imposing a limited menu of commands; this scheme as‐
3961       sumes that the end-user does not have write and execute permissions  in
3962       the same directory.
3963
3964       The  net  effect  of these rules is that the writer of the .profile has
3965       complete control over user actions, by performing guaranteed setup  ac‐
3966       tions  and  leaving  the user in an appropriate directory (probably not
3967       the login directory).
3968
3969       The system administrator often sets up a directory of  commands  (e.g.,
3970       /usr/rbin) that can be safely invoked by rksh.
3971

EXIT STATUS

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

FILES

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

SEE ALSO

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

CAVEATS

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