KSH(1)

KSH(1)

pdftotext Home Page User Commands Index pedal


NAME
       ksh - Public domain Korn shell

SYNOPSIS
       ksh [+-abCefhikmnprsuvxX] [+-o option] [ [ -c command-
       string [command-name] | -s | file ] [argument ...] ]

DESCRIPTION
       ksh is a command interpreter that  is  intended  for  both
       interactive and shell script use.  Its command language is
       a superset of the sh(1) shell language.

   Shell Startup
       The following options can be specified only on the command
       line:

       -c command-string
              the shell executes the command(s) contained in com-
              mand-string

       -i     interactive mode -- see below

       -l     login shell -- see below interactive  mode  --  see
              below

       -s     the  shell  reads commands from standard input; all
              non-option arguments are positional parameters

       -r     restricted mode -- see below

       In addition to the above, the options described in the set
       built-in command can also be used on the command line.

       If  neither  the  -c nor the -s options are specified, the
       first non-option argument specifies the name of a file the
       shell  reads  commands  from;  if  there are no non-option
       arguments, the shell reads commands from  standard  input.
       The  name  of  the  shell  (i.e.,  the contents of the $0)
       parameter is determined as follows: if the  -c  option  is
       used and there is a non-option argument, it is used as the
       name; if commands are being read from a file, the file  is
       used  as the name; otherwise the name the shell was called
       with (i.e., argv[0]) is used.

       A shell is interactive if the -i option is used or if both
       standard  input  and standard error are attached to a tty.
       An interactive shell has job control  enabled  (if  avail-
       able),  ignores the INT, QUIT and TERM signals, and prints
       prompts before reading input (see PS1 and PS2 parameters).
       For  non-interactive  shells, the trackall option is on by
       default (see set command below).

       A shell is restricted if the  -r  option  is  used  or  if
       either  the basename of the name the shell is invoked with

       or the SHELL parameter match the pattern *r*sh (e.g., rsh,
       rksh, rpdksh, etc.).  The following restrictions come into
       effect after the shell  processes  any  profile  and  $ENV
       files:
         +o    the cd command is disabled
         +o    the SHELL, ENV and PATH parameters can't be changed
         +o    command names can't be specified with  absolute  or
              relative paths
         +o    the -p option of the command built-in can't be used
         +o    redirections that create files can't be used (i.e.,
              >>, >>|, >>>>, <<>>)

       A  shell  is privileged if the -p option is used or if the
       real user-id or group-id  does  not  match  the  effective
       user-id  or group-id (see getuid(2), getgid(2)).  A privi-
       leged shell does not process $HOME/.profile  nor  the  ENV
       parameter  (see below), instead the file /etc/suid_profile
       is processed.  Clearing the privileged option  causes  the
       shell  to set its effective user-id (group-id) to its real
       user-id (group-id).

       If the basename of the  name  the  shell  is  called  with
       (i.e., argv[0]) starts with - or if the -l option is used,
       the shell is assumed to be a login  shell  and  the  shell
       reads  and  executes  the  contents  of  /etc/profile  and
       $HOME/.profile if they exist and are readable.

       If the ENV parameter is set when the shell starts (or,  in
       the  case  of  login  shells,  after any profiles are pro-
       cessed), its value is  subjected  to  parameter,  command,
       arithmetic  and  tilde substitution and the resulting file
       (if any) is read and executed.  If ENV  parameter  is  not
       set  (and  not  null)  and  pdksh  was  compiled  with the
       DEFAULT_ENV macro defined, the file named in that macro is
       included  (after  the  above  mentioned substitutions have
       been performed).

       The exit status of the shell is 127 if  the  command  file
       specified on the command line could not be opened, or non-
       zero if a fatal syntax error occurred during the execution
       of  a  script.   In  the absence of fatal errors, the exit
       status is that of the last command executed, or  zero,  if
       no command is executed.

   Command Syntax
       The  shell  begins  parsing  its input by breaking it into
       words.  Words, which  are  sequences  of  characters,  are
       delimited  by  unquoted white-space characters (space, tab
       and newline) or meta-characters (<<, >>, |, ;, &, ( and  )).
       Aside  from delimiting words, spaces and tabs are ignored,
       while newlines usually delimit commands.  The meta-charac-
       ters are used in building the following tokens: <<, <<&, <<<<,
       >>, >>&, >>>>, etc. are  used  to  specify  redirections  (see
       Input/Output  Redirection  below);  |  is  used  to create

       pipelines; |& is used to create co-processes (see  Co-Pro-
       cesses  below);  ; is used to separate commands; & is used
       to create asynchronous pipelines; && and ||  are  used  to
       specify  conditional  execution; ;; is used in case state-
       ments; (( .. )) are used in  arithmetic  expressions;  and
       lastly, ( .. ) are used to create subshells.

       White-space and meta-characters can be quoted individually
       using backslash (\), or in groups using double (") or sin-
       gle  (')  quotes.   Note that the following characters are
       also treated specially by the shell and must be quoted  if
       they  are to represent themselves: \, ", ', #, $, `, ~, {,
       }, *, ? and [.  The first three of  these  are  the  above
       mentioned  quoting  characters  (see Quoting below); #, if
       used at the beginning of a word, introduces a  comment  --
       everything  after  the  #  up  to  the  nearest newline is
       ignored; $ is used to  introduce  parameter,  command  and
       arithmetic   substitutions  (see  Substitution  below);  `
       introduces an old-style command substitution (see  Substi-
       tution  below);  ~ begins a directory expansion (see Tilde
       Expansion below); { and } delimit  csh(1)  style  alterna-
       tions  (see Brace Expansion below); and, finally, *, ? and
       [ are used in file name generation (see File Name Patterns
       below).

       As words and tokens are parsed, the shell builds commands,
       of which there are two basic types: simple-commands, typi-
       cally  programs  that are executed, and compound-commands,
       such as for and if  statements,  grouping  constructs  and
       function definitions.

       A simple-command consists of some combination of parameter
       assignments (see Parameters below), input/output  redirec-
       tions  (see  Input/Output Redirections below), and command
       words; the only restriction is that parameter  assignments
       come before any command words.  The command words, if any,
       define the command that is to be executed  and  its  argu-
       ments.   The  command  may  be a shell built-in command, a
       function or an external command,  i.e.,  a  separate  exe-
       cutable file that is located using the PATH parameter (see
       Command Execution below).   Note  that  all  command  con-
       structs  have  an exit status: for external commands, this
       is related to the status returned by wait(2) (if the  com-
       mand  could  not  be  found, the exit status is 127, if it
       could not be executed, the exit status is 126);  the  exit
       status  of  other  command  constructs (built-in commands,
       functions, compound-commands, pipelines, lists, etc.)  are
       all  well defined and are described where the construct is
       described.  The exit status of a command  consisting  only
       of  parameter assignments is that of the last command sub-
       stitution performed during  the  parameter  assignment  or
       zero if there were no command substitutions.

       Commands can be chained together using the | token to form

       pipelines, in which the standard output  of  each  command
       but  the last is piped (see pipe(2)) to the standard input
       of the following command.  The exit status of  a  pipeline
       is  that  of its last command.  A pipeline may be prefixed
       by the ! reserved word which causes the exit status of the
       pipeline  to  be  logically  complemented: if the original
       status was 0 the complemented status will be 1, and if the
       original  status  was  not 0, then the complemented status
       will be 0.

       Lists of commands can be created by  separating  pipelines
       by  any of the following tokens: &&, ||, &, |& and ;.  The
       first two are for conditional execution: cmd1 && cmd2 exe-
       cutes  cmd2 only if the exit status of cmd1 is zero; || is
       the opposite -- cmd2 is executed only if the  exit  status
       of  cmd1  is  non-zero.   &&  and || have equal precedence
       which is higher than that of &, |& and ;, which also  have
       equal  precedence.   The & token causes the preceding com-
       mand to be executed asynchronously,  that  is,  the  shell
       starts  the  command, but does not wait for it to complete
       (the shell does keep track of the status  of  asynchronous
       commands  -- see Job Control below).  When an asynchronous
       command is started when job control is disabled (i.e.,  in
       most scripts), the command is started with signals INT and
       QUIT ignored and  with  input  redirected  from  /dev/null
       (however,  redirections specified in the asynchronous com-
       mand have precedence).  The |& operator starts  a  co-pro-
       cess  which  is  special kind of asynchronous process (see
       Co-Processes below).  Note that a command must follow  the
       && and || operators, while a command need not follow &, |&
       and ;.  The exit status of a list is that of the last com-
       mand  executed,  with the exception of asynchronous lists,
       for which the exit status is 0.

       Compound commands are created using the following reserved
       words  --  these  words  are  only  recognized if they are
       unquoted and if they are used as the first word of a  com-
       mand  (i.e.,  they  can't be preceded by parameter assign-
       ments or redirections):
                  case   else   function   then    !
                  do     esac   if         time    [[
                  done   fi     in         until   {
                  elif   for    select     while   }
       Note: Some shells  (but  not  this  one)  execute  control
       structure commands in a subshell when one or more of their
       file  descriptors  are  redirected,  so  any   environment
       changes  inside  them  may fail.  To be portable, the exec
       statement should be used instead to redirect file descrip-
       tors before the control structure.

       In  the  following  compound command descriptions, command
       lists (denoted as list)  that  are  followed  by  reserved
       words  must end with a semi-colon, a newline or a (syntac-
       tically correct) reserved word.  For example,
              { echo foo; echo bar; }
              { echo foo; echo bar<<newline>>}
              { { echo foo; echo bar; } }
       are all valid, but
              { echo foo; echo bar }
       is not.

       ( list )
              Execute list in a subshell.  There is  no  implicit
              way  to  pass  environment  changes from a subshell
              back to its parent.

       { list }
              Compound construct; list is executed, but not in  a
              subshell.   Note  that  { and } are reserved words,
              not meta-characters.

       case word in [ [(] pattern [| pattern] ... ) list ;; ] ...
              esac
              The  case  statement attempts to match word against
              the specified patterns; the  list  associated  with
              the first successfully matched pattern is executed.
              Patterns used in case statements are  the  same  as
              those  used  for file name patterns except that the
              restrictions regarding . and / are  dropped.   Note
              that  any unquoted space before and after a pattern
              is stripped; any  space  with  a  pattern  must  be
              quoted.  Both the word and the patterns are subject
              to parameter, command, and arithmetic  substitution
              as well as tilde substitution.  For historical rea-
              sons, open and close braces may be used instead  of
              in  and  esac  (e.g.,  case $foo { *) echo bar; }).
              The exit status of a case statement is that of  the
              executed  list;  if  no  list is executed, the exit
              status is zero.

       for name [ in word ... term ] do list done
              where term is either a newline or a  ;.   For  each
              word in the specified word list, the parameter name
              is set to the word and list is executed.  If in  is
              not  used  to  specify  a word list, the positional
              parameters ("$1", "$2",  etc.)  are  used  instead.
              For  historical  reasons, open and close braces may
              be used instead of do and done (e.g., for i; { echo
              $i;  }).  The exit status of a for statement is the
              last exit status of list; if  list  is  never  exe-
              cuted, the exit status is zero.

       if list then list [elif list then list] ... [else list] fi
              If the exit status of the first list is  zero,  the
              second list is executed; otherwise the list follow-
              ing the elif, if any, is executed with similar con-
              sequences.   If  all the lists following the if and
              elifs fail (i.e., exit with non-zero  status),  the
              list following the else is executed.  The exit sta-
              tus of an if statement is that  of  non-conditional
              list  that  is executed; if no non-conditional list
              is executed, the exit status is zero.

       select name [ in word ... term ] do list done
              where term is either a newline or a ;.  The  select
              statement  provides an automatic method of present-
              ing the user with a menu and selecting from it.  An
              enumerated  list  of the specified words is printed
              on standard error, followed by a prompt (PS3,  nor-
              mally `#? ').  A number corresponding to one of the
              enumerated words is then read from standard  input,
              name  is  set  to the selected word (or is unset if
              the selection is not valid), REPLY is set  to  what
              was  read (leading/trailing space is stripped), and
              list is executed.  If a blank line (i.e.,  zero  or
              more  IFS  characters)  is entered, the menu is re-
              printed without executing  list.   When  list  com-
              pletes,  the enumerated list is printed if REPLY is
              null, the prompt is printed and so on.   This  pro-
              cess  is continues until an end-of-file is read, an
              interrupt is received or a break statement is  exe-
              cuted  inside the loop.  If in word ... is omitted,
              the positional parameters  are  used  (i.e.,  "$1",
              "$2",  etc.).   For  historical  reasons,  open and
              close braces may be used instead  of  do  and  done
              (e.g., select i; { echo $i; }).  The exit status of
              a select statement is zero if a break statement  is
              used to exit the loop, non-zero otherwise.

       until list do list done
              This works like while, except that the body is exe-
              cuted only while the exit status of the first  list
              is non-zero.

       while list do list done
              A while is a prechecked loop.  Its body is executed
              as often as the exit status of the  first  list  is
              zero.   The exit status of a while statement is the
              last exit status of the list in  the  body  of  the
              loop;  if the body is not executed, the exit status
              is zero.

       function name { list }
              Defines the function name.   See  Functions  below.
              Note  that  redirections specified after a function
              definition are performed whenever the  function  is
              executed,  not when the function definition is exe-
              cuted.

       name () command
              Mostly the same as function.  See Functions  below.

       (( expression ))
              The  arithmetic expression expression is evaluated;
              equivalent to  let  "expression".   See  Arithmetic
              Expressions and the let command below.

       [[ expression ]]
              Similar to the test and [ ... ] commands (described
              later), with the following exceptions:
                +o    Field splitting and file name generation are
                     not performed on arguments.
                +o    The  -a  (and)  and  -o  (or)  operators are
                     replaced with && and ||, respectively.
                +o    Operators (e.g., -f, =,  !,  etc.)  must  be
                     unquoted.
                +o    The  second  operand of != and = expressions
                     are patterns (e.g., the comparison in
                                  [[ foobar = f*r ]]
                     succeeds).
                +o    There are two additional binary operators: <<
                     and  >>  which  return  true  if  their first
                     string operand  is  less  than,  or  greater
                     than,  their  second string operand, respec-
                     tively.
                +o    The single  argument  form  of  test,  which
                     tests  if  the argument has non-zero length,
                     is not valid - explicit  operators  must  be
                     always be used, e.g., instead of
                                       [ str ]
                     use
                                     [[ -n str ]]
                +o    Parameter,  command and arithmetic substitu-
                     tions are performed as expressions are eval-
                     uated and lazy expression evaluation is used
                     for the && and  ||  operators.   This  means
                     that in the statement
                            [[ -r foo && $(<< foo) = b*r ]]
                     the $(<< foo) is evaluated if and only if the
                     file foo exists and is readable.

   Quoting
       Quoting is used to prevent the shell from treating charac-
       ters or words specially.  There are three methods of quot-
       ing: First, \ quotes the following character, unless it is
       at  the  end  of  a line, in which case both the \ and the
       newline are stripped.  Second, a single quote  (')  quotes
       everything  up  to  the  next  single quote (this may span
       lines).  Third, a double quote (") quotes all  characters,
       except  $,  ` and \, up to the next unquoted double quote.
       $ and ` inside double  quotes  have  their  usual  meaning
       (i.e.,  parameter,  command  or  arithmetic  substitution)
       except no field splitting is carried out on the results of
       double-quoted  substitutions.   If  a  \  inside a double-
       quoted string is followed by \, $, ` or ", it is  replaced
       by  the  second character; if it is followed by a newline,

       both the \ and the newline are stripped;  otherwise,  both
       the \ and the character following are unchanged.

       Note:  see  POSIX  Mode below for a special rule regarding
       sequences of the form "...`...\"...`..".

   Aliases
       There are two types of aliases: normal command aliases and
       tracked  aliases.   Command aliases are normally used as a
       short hand for a long or often used  command.   The  shell
       expands  command aliases (i.e., substitutes the alias name
       for its value) when it reads the first word of a  command.
       An  expanded  alias  is  re-processed  to  check  for more
       aliases.  If a command alias ends in a space or  tab,  the
       following  word  is also checked for alias expansion.  The
       alias expansion process stops when a word that is  not  an
       alias  is  found,  when  a quoted word is found or when an
       alias word that is currently being expanded is found.

       The following command aliases are defined automatically by
       the shell:
              autoload='typeset -fu'
              functions='typeset -f'
              hash='alias -t'
              history='fc -l'
              integer='typeset -i'
              local='typeset'
              login='exec login'
              newgrp='exec newgrp'
              nohup='nohup '
              r='fc -e -'
              stop='kill -STOP'
              suspend='kill -STOP $$'
              type='whence -v'

       Tracked aliases allow the shell to remember where it found
       a particular command.  The first time  the  shell  does  a
       path  search  for  a  command  that is marked as a tracked
       alias, it saves the full path of the  command.   The  next
       time  the  command is executed, the shell checks the saved
       path to see that it is still  valid,  and  if  so,  avoids
       repeating  the path search.  Tracked aliases can be listed
       and created using alias -t.  Note that changing  the  PATH
       parameter  clears the saved paths for all tracked aliases.
       If the trackall option is set (i.e., set  -o  trackall  or
       set  -h),  the  shell tracks all commands.  This option is
       set automatically for non-interactive shells.  For  inter-
       active  shells,  only the following commands are automati-
       cally tracked: cat, cc, chmod, cp, date, ed, emacs,  grep,
       ls, mail, make, mv, pr, rm, sed, sh, vi and who.

   Substitution
       The  first step the shell takes in executing a simple-com-
       mand is to perform  substitutions  on  the  words  of  the

       command.   There  are three kinds of substitution: parame-
       ter, command  and  arithmetic.   Parameter  substitutions,
       which  are  described  in detail in the next section, take
       the form $name or ${...}; command substitutions  take  the
       form $(command) or `command`; and arithmetic substitutions
       take the form $((expression)).

       If a substitution appears outside of  double  quotes,  the
       results  of the substitution are generally subject to word
       or field splitting according to the current value  of  the
       IFS  parameter.   The  IFS  parameter  specifies a list of
       characters which are used to break a string up  into  sev-
       eral  words;  any  characters  from the set space, tab and
       newline that appear in the IFS characters are  called  IFS
       white  space.   Sequences  of  one or more IFS white space
       characters, in combination with zero or one non-IFS  white
       space  characters  delimit  a  field.   As a special case,
       leading and trailing IFS white space is stripped (i.e., no
       leading or trailing empty field is created by it); leading
       or trailing non-IFS  white  space  does  create  an  empty
       field.  Example: if IFS is set to `<space>:', the sequence
       of  characters  `<space>A<space>:<space><space>B::D'  con-
       tains four fields: `A', `B', `' and `D'.  Note that if the
       IFS parameter is set to the null string, no  field  split-
       ting is done; if the parameter is unset, the default value
       of space, tab and newline is used.

       The results of substitution are, unless  otherwise  speci-
       fied, also subject to brace expansion and file name expan-
       sion (see the relevant sections below).

       A command substitution is replaced by the output generated
       by the specified command, which is run in a subshell.  For
       $(command) substitutions, normal quoting  rules  are  used
       when command is parsed, however, for the `command` form, a
       \ followed by any of $, ` or \ is stripped (a  \  followed
       by  any  other character is unchanged).  As a special case
       in command substitutions, a command of the form << file  is
       interpreted  to  mean substitute the contents of file ($(<
       foo) has the same effect as $(cat foo), but it is  carried
       out more efficiently because no process is started).
       NOTE: $(command) expressions are currently parsed by find-
       ing the matching parenthesis, regardless of quoting.  This
       will hopefully be fixed soon.

       Arithmetic  substitutions are replaced by the value of the
       specified  expression.   For  example,  the  command  echo
       $((2+3*4))  prints  14.   See Arithmetic Expressions for a
       description of an expression.

   Parameters
       Parameters are shell variables; they can be assigned  val-
       ues  and  their  values  can be accessed using a parameter
       substitution.  A parameter  name  is  either  one  of  the

       special  single  punctuation or digit character parameters
       described below, or a letter followed by zero or more let-
       ters  or  digits (`_' counts as a letter).  Parameter sub-
       stitutions take the form $name or ${name}, where name is a
       parameter name.  If substitution is performed on a parame-
       ter that is not set, a null string is  substituted  unless
       the  nounset  option (set -o nounset or set -u) is set, in
       which case an error occurs.

       Parameters can be assigned values in  a  number  of  ways.
       First,  the  shell implicitly sets some parameters like #,
       PWD, etc.; this is the only way the special single charac-
       ter  parameters  are set.  Second, parameters are imported
       from the shell's environment at startup.   Third,  parame-
       ters can be assigned values on the command line, for exam-
       ple, `FOO=bar' sets the parameter  FOO  to  bar;  multiple
       parameter  assignments  can  be  given on a single command
       line and they can be  followed  by  a  simple-command,  in
       which  case  the  assignments  are  in effect only for the
       duration  of  the  command  (such  assignments  are   also
       exported,  see below for implications of this).  Note that
       both the parameter name and the = must be unquoted for the
       shell to recognize a parameter assignment.  The fourth way
       of setting a parameter is with the  export,  readonly  and
       typeset  commands;  see  their descriptions in the Command
       Execution section.  Fifth, for and select loops set param-
       eters  as  well  as the getopts, read and set -A commands.
       Lastly, parameters can be assigned values using assignment
       operators  inside  arithmetic  expressions (see Arithmetic
       Expressions below) or  using  the  ${name=value}  form  of
       parameter substitution (see below).

       Parameters with the export attribute (set using the export
       or typeset -x commands, or by parameter  assignments  fol-
       lowed  by simple commands) are put in the environment (see
       environ(5)) of commands run by  the  shell  as  name=value
       pairs.   The order in which parameters appear in the envi-
       ronment of a  command  is  unspecified.   When  the  shell
       starts  up,  it  extracts parameters and their values from
       its  environment  and  automatically   sets   the   export
       attribute for those parameters.

       Modifiers  can be applied to the ${name} form of parameter
       substitution:

       ${name:-word}
              if name is set and not  null,  it  is  substituted,
              otherwise word is substituted.

       ${name:+word}
              if  name  is set and not null, word is substituted,
              otherwise nothing is substituted.

       ${name:=word}
              if name is set and not  null,  it  is  substituted,
              otherwise  it  is  assigned  word and the resulting
              value of name is substituted.

       ${name:?word}
              if name is set and not  null,  it  is  substituted,
              otherwise  word  is printed on standard error (pre-
              ceded by name:) and an error occurs (normally caus-
              ing  termination  of  a  shell  script, function or
              .-script).  If word is omitted the string  `parame-
              ter null or not set' is used instead.

       In  the  above  modifiers,  the : can be omitted, in which
       case the conditions only depend  on  name  being  set  (as
       opposed  to set and not null).  If word is needed, parame-
       ter, command, arithmetic and tilde substitution  are  per-
       formed  on it; if word is not needed, it is not evaluated.

       The following forms of parameter substitution can also  be
       used:

       ${#name}
              The number of positional parameters if name is *, @
              or is not specified, or the length  of  the  string
              value of parameter name.

       ${#name[*]}, ${#name[@]}
              The number of elements in the array name.

       ${name#pattern}, ${name##pattern}
              If  pattern  matches  the beginning of the value of
              parameter name, the matched text  is  deleted  from
              the  result of substitution.  A single # results in
              the shortest match, two #'s results in the  longest
              match.

       ${name%pattern}, ${name%%pattern}
              Like ${..#..} substitution, but it deletes from the
              end of the value.

       The following special parameters are implicitly set by the
       shell and cannot be set directly using assignments:

       !      Process  id of the last background process started.
              If no background processes have been  started,  the
              parameter is not set.

       #      The  number of positional parameters (i.e., $1, $2,
              etc.).

       $      The process ID of the shell,  or  the  PID  of  the
              original shell if it is a subshell.

       -      The  concatenation  of  the  current  single letter
              options  (see  set  command  below  for   list   of
              options).

       ?      The  exit  status of the last non-asynchronous com-
              mand executed.  If the last command was killed by a
              signal, $? is set to 128 plus the signal number.

       0      The   name   the  shell  was  invoked  with  (i.e.,
              argv[0]), or the command-name  if  it  was  invoked
              with  the  -c  option and the command-name was sup-
              plied, or the file argument, if  it  was  supplied.
              If  the  posix option is not set, $0 is the name of
              the current function or script.

       1 ... 9
              The first nine positional parameters that were sup-
              plied  to the shell, function or .-script.  Further
              positional parameters may be accessed using  ${num-
              ber}.

       *      All  positional  parameters  (except  parameter 0),
              i.e., $1 $2  $3....   If  used  outside  of  double
              quotes,  parameters  are  separate words (which are
              subjected to word splitting); if used within double
              quotes, parameters are separated by the first char-
              acter of the IFS parameter (or the empty string  if
              IFS is null).

       @      Same as $*, unless it is used inside double quotes,
              in which case a separate word is generated for each
              positional  parameter  - if there are no positional
              parameters, no word is generated ("$@" can be  used
              to access arguments, verbatim, without loosing null
              arguments or splitting arguments with spaces).

       The following parameters are set and/or used by the shell:

       _ (underscore)
              In  interactive  use,  this parameter is set to the
              last word of the previous command.  When a  command
              is executed, this parameter is set to the full path
              of the command and is placed in the command's envi-
              ronment.   When  MAILPATH  messages  are evaluated,
              this parameter contains the name of the  file  that
              changed (see MAILPATH parameter below).

       CDPATH Search path for the cd built-in command.  Works the
              same way as PATH for those directories  not  begin-
              ning with / in cd commands.  Note that if CDPATH is
              set and does not contain . nor an empty  path,  the
              current directory is not searched.

       COLUMNS
              Set  to  the  number  of columns on the terminal or
              window.   Currently  set  to  the  cols  value   as
              reported  by  stty(1)  if  that  value is non-zero.
              This parameter is  used  by  the  interactive  line
              editing  modes,  and  by select, set -o and kill -l
              commands to format information in columns.

       EDITOR If the VISUAL parameter is not set, this  parameter
              controls the command line editing mode for interac-
              tive shells.  See VISUAL parameter  below  for  how
              this works.

       ENV    If this parameter is found to be set after any pro-
              file files are executed, the expanded value is used
              as  a  shell  start-up file.  It typically contains
              function and alias definitions.

       ERRNO  Integer value of  the  shell's  errno  variable  --
              indicates the reason the last system call failed.
              Not implemented yet.

       EXECSHELL
              If  set,  this  parameter is assumed to contain the
              shell that is to be used to execute  commands  that
              execve(2)  fails  to execute and which do not start
              with a `#! shell' sequence.

       FCEDIT The editor used by the fc command (see below).

       FPATH  Like PATH, but used when an undefined  function  is
              executed  to locate the file defining the function.
              It is also searched when a command can't  be  found
              using  PATH.  See Functions below for more informa-
              tion.

       HISTFILE
              The name of the file used to store  history.   When
              assigned  to,  history is loaded from the specified
              file.  Also, several invocations of the shell  run-
              ning  on  the  same  machine  will share history if
              their HISTFILE parameters all  point  at  the  same
              file.
              NOTE:  if  HISTFILE  isn't  set, no history file is
              used.  This is different  from  the  original  Korn
              shell,  which  uses  $HOME/.sh_history;  in future,
              pdksh may also use a default history file.

       HISTSIZE
              The number of commands normally stored for history,
              default 128.

       HOME   The  default  directory  for the cd command and the
              value substituted for an unqualified ~  (see  Tilde
              Expansion below).

       IFS    Internal  field separator, used during substitution
              and by the read command, to split values into  dis-
              tinct  arguments;  normally  set  to space, tab and
              newline.  See Substitution above for details.
              Note: this parameter is not imported from the envi-
              ronment when the shell is started.

       KSH_VERSION
              The  version  of shell and the date the version was
              created (readonly).  See also the version  commands
              in  Emacs  Interactive  Input  Line  Editing and Vi
              Interactive Input Line Editing, below.

       LINENO The line number of the  function  or  shell  script
              that is currently being executed.
              Not implemented yet.

       LINES  Set  to the number of lines on the terminal or win-
              dow.
              Not implemented yet.

       MAIL   If set, the user will be informed of the arrival of
              mail  in the named file.  This parameter is ignored
              if the MAILPATH parameter is set.

       MAILCHECK
              How often, in seconds, the  shell  will  check  for
              mail  in the file(s) specified by MAIL or MAILPATH.
              If 0, the shell checks  before  each  prompt.   The
              default is 600 (10 minutes).

       MAILPATH
              A  list  of files to be checked for mail.  The list
              is colon separated, and each file may  be  followed
              by  a ? and a message to be printed if new mail has
              arrived.  Command, parameter and arithmetic substi-
              tution  is  performed  on  the message, and, during
              substitution, the parameter $_ contains the name of
              the  file.  The default message is you have mail in
              $_.

       OLDPWD The previous working directory.  Unset  if  cd  has
              not  successfully  changed  directories  since  the
              shell started, or if the shell doesn't  know  where
              it is.

       OPTARG When  using getopts, it contains the argument for a
              parsed option, if it requires one.

       OPTIND The index of the last argument processed when using
              getopts.   Assigning  1  to  this  parameter causes
              getopts to process arguments from the beginning the
              next time it is invoked.

       PATH   A  colon  separated  list  of  directories that are
              searched when looking for commands and  .'d  files.
              An  empty string resulting from a leading or trail-
              ing colon, or two adjacent colons is treated  as  a
              `.', the current directory.

       POSIXLY_CORRECT
              If  set,  this parameter causes the posix option to
              be enabled.  See POSIX Mode below.

       PPID   The process ID of the shell's parent (readonly).

       PS1    PS1 is the primary prompt for  interactive  shells.
              Parameter, command and arithmetic substitutions are
              performed, and ! is replaced with the current  com-
              mand  number  (see  fc command below).  A literal !
              can be put in the prompt  by  placing  !!  in  PS1.
              Note  that  since  the  command line editors try to
              figure out how long the prompt is (so they know how
              far  it  is to edge of the screen), escape codes in
              the prompt tend to mess things up.   You  can  tell
              the  shell  not to count certain sequences (such as
              escape codes) by prefixing your prompt with a  non-
              printing  character (such as control-A) followed by
              a carriage return and then  delimiting  the  escape
              codes  with  this  non-printing  character.  If you
              don't have any non-printing characters, you're  out
              of luck...  BTW, don't blame me for this hack; it's
              in the original ksh.  Default is `$ ' for  non-root
              users, `# ' for root..

       PS2    Secondary prompt string, by default `>> ', used when
              more input is needed to complete a command.

       PS3    Prompt used by select statement when reading a menu
              selection.  Default is `#? '.

       PS4    Used  to  prefix  commands  that are printed during
              execution  tracing  (see  set  -x  command  below).
              Parameter, command and arithmetic substitutions are
              performed before it is printed.  Default is `+ '.

       PWD    The current working directory.  Maybe unset or null
              if shell doesn't know where it is.

       RANDOM A  simple random number generator.  Every time RAN-
              DOM is referenced, it is assigned the  next  number
              in a random number series.  The point in the series
              can be set by assigning a  number  to  RANDOM  (see
              rand(3)).

       REPLY  Default  parameter for the read command if no names
              are given.  Also used in select loops to store  the
              value that is read from standard input.

       SECONDS
              The  number  of seconds since the shell started or,
              if the  parameter  has  been  assigned  an  integer
              value,  the  number of seconds since the assignment
              plus the value that was assigned.

       TMOUT  If set to a  positive  integer  in  an  interactive
              shell,  it  specifies the maximum number of seconds
              the shell will wait for input  after  printing  the
              primary prompt (PS1).  If the time is exceeded, the
              shell exits.

       TMPDIR The directory shell temporary files are created in.
              If  this  parameter is not set, or does not contain
              the absolute path of a writable  directory,  tempo-
              rary files are created in /tmp.

       VISUAL If  set,  this  parameter controls the command line
              editing mode for interactive shells.  If  the  last
              component  of  the path specified in this parameter
              contains the string vi, emacs  or  gmacs,  the  vi,
              emacs  or  gmacs  (Gosling  emacs)  editing mode is
              enabled, respectively.

   Tilde Expansion
       Tilde expansion, which is done in parallel with  parameter
       substitution,  is  done on words starting with an unquoted
       ~.  The characters following the tilde, up to the first /,
       if any, are assumed to be a login name.  If the login name
       is empty, + or -, the value of the HOME,  PWD,  or  OLDPWD
       parameter  is  substituted,  respectively.  Otherwise, the
       password file is searched for  the  login  name,  and  the
       tilde  expression  is  substituted  with  the  user's home
       directory.  If the login name is not found in the password
       file or if any quoting or parameter substitution occurs in
       the login name, no substitution is performed.

       In parameter assignments (those preceding a simple-command
       or  those  occurring  in  the  arguments of alias, export,
       readonly, and typeset), tilde expansion is done after  any
       unquoted  colon (:), and login names are also delimited by
       colons.

       The home directory of previously expanded login names  are
       cached  and  re-used.  The alias -d command may be used to
       list, change and  add  to  this  cache  (e.g.,  `alias  -d
       fac=/usr/local/facilities; cd ~fac/bin').

   Brace Expansion (alternation)
       Brace expressions, which take the form
              prefix{str1,...,strN}suffix
       are  expanded  to N words, each of which is the concatena-
       tion of prefix, stri and  suffix  (e.g.,  `a{c,b{X,Y},d}e'
       expands to four word: ace, abXe, abYe, and ade).  As noted
       in the example, brace expressions can be  nested  and  the
       resulting  words  are  not sorted.  Brace expressions must
       contain an unquoted  comma  (,)  for  expansion  to  occur
       (i.e., {} and {foo} are not expanded).  Brace expansion is
       carried out after parameter substitution and  before  file
       name generation.

   File Name Patterns
       A  file  name  pattern  is  a  word containing one or more
       unquoted ? or * characters or [..] sequences.  Once  brace
       expansion has been performed, the shell replaces file name
       patterns with the sorted names of all the files that match
       the   pattern  (if  no  files  match,  the  word  is  left
       unchanged).  The pattern elements have the following mean-
       ing:

       ?      matches any single character.

       *      matches any sequence of characters.

       [..]   matches  any of the characters inside the brackets.
              Ranges of characters can be specified by separating
              two  characters  by  a  -, e.g., [a0-9] matches the
              letter a or  any  digit.   In  order  to  represent
              itself,  a  - must either be quoted or the first or
              last character in the character list.  Similarly, a
              ] must be quoted or the first character in the list
              if it is represent itself instead of the end of the
              list.   Also,  a  !   appearing at the start of the
              list has special meaning (see below), so to  repre-
              sent  itself  it  must be quoted or appear later in
              the list.

       [!..]  like [..], except  it  matches  any  character  not
              inside the brackets.

       *(pattern| ... |pattern)
              matches  any string of characters that matches zero
              or  more  occurances  of  the  specified  patterns.
              Example: the pattern *(foo|bar) matches the strings
              `', `foo', `bar', `foobarfoo', etc..

       +(pattern| ... |pattern)
              matches any string of characters that  matches  one
              or  more  occurances  of  the  specified  patterns.
              Example: the pattern +(foo|bar) matches the strings
              `foo', `bar', `foobarfoo', etc..

       ?(pattern| ... |pattern)
              matches  the  empty string or a string that matches
              one of the specified patterns.  Example:  the  pat-
              tern  ?(foo|bar) only matches the strings `', `foo'
              and `bar'.

       @(pattern| ... |pattern)
              matches a string that matches one of the  specified
              patterns.   Example:  the  pattern  @(foo|bar) only
              matches the strings `foo' and `bar'.

       !(pattern| ... |pattern)
              matches any string that does not match one  of  the
              specified    patterns.    Examples:   the   pattern
              !(foo|bar) matches all  strings  except  `foo'  and
              `bar';  the  pattern  !(*)  matches no strings; the
              pattern !(?)* matches all strings (think about it).

       Note  that pdksh currently never matches . and .., but the
       original ksh, Bourne sh and bash do, so this may  have  to
       change (too bad).

       Note  that none of the above pattern elements match either
       a period (.)  at the start of a file name or a slash  (/),
       even if they are explicitly used in a [..] sequence; also,
       the names . and ..  are never matched, even by the pattern
       .*.

       If the markdirs option is set, any directories that result
       from file name generation are marked with a trailing /.

       The POSIX character classes (i.e., [:class-name:] inside a
       [..] expression) are not yet implemented.

   Input/Output Redirection
       When  a  command is executed, its standard input, standard
       output and standard error (file descriptors 0,  1  and  2,
       respectively)  are  normally  inherited  from  the  shell.
       Three exceptions to this are commands  in  pipelines,  for
       which  standard input and/or standard output are those set
       up by the pipeline, asynchronous commands created when job
       control is disabled, for which standard input is initially
       set to be from /dev/null, and commands for  which  any  of
       the following redirections have been specified:

       >> file standard  output  is  redirected  to file.  If file
              does not exist, it is created; if it does exist, is
              a  regular file and the noclobber option is set, an
              error occurs,  otherwise  the  file  is  truncated.
              Note  that  this  means the command cmd &lt; foo > foo
              will open foo for reading and then truncate it when
              it  opens  it for writing, before cmd gets a chance
              to actually read foo.

       >>| file
              same as >>, except the file is  truncated,  even  if
              the noclobber option is set.

       >>>> file
              same  as  >>,  except  the  file an existing file is
              appended to instead of being truncated.  Also,  the
              file  is opened in append mode, so writes always go
              to the end of the file (see open(2)).

       << file standard input is redirected from  file,  which  is
              opened for reading.

       <<>> file
              same  as  <<,  except the file is opened for reading
              and writing.

       <<<< marker
              after reading the command line containing this kind
              of  redirection (called a here document), the shell
              copies lines from the command source into a  tempo-
              rary  file  until  a  line matching marker is read.
              When the command is  executed,  standard  input  is
              redirected from the temporary file.  If marker con-
              tains no quoted characters,  the  contents  of  the
              temporary file are processed as if enclosed in dou-
              ble quotes each time the command  is  executed,  so
              parameter, command and arithmetic substitutions are
              performed, along with backslash (\) escapes for  $,
              `,  \ and \newline.  If multiple here documents are
              used on the same command line, they  are  saved  in
              order.

       <<<<- marker
              same  as  <<<<, except leading tabs are stripped from
              lines in the here document.

       <<& fd  standard input is duplicated from  file  descriptor
              fd.   fd can be a single digit, indicating the num-
              ber of an existing file descriptor, the  letter  p,
              indicating  the file descriptor associated with the
              output of the current co-process, or the  character
              -, indicating standard input is to be closed.

       >>& fd  same  as  <<&, except the operation is done on stan-
              dard output.

       In any of the above redirections, the file descriptor that
       is  redirected  (i.e.,  standard input or standard output)
       can be explicitly given by preceding the redirection  with
       a single digit.  Parameter, command and arithmetic substi-
       tutions, tilde substitutions and file name generation  are
       all  performed  on  the  file,  marker and fd arguments of
       redirections.  Note however, that the results of any  file

       name generation are only used if a single file is matched;
       if multiple files match, the word with the unexpanded file
       name   generation   characters  is  used.   Note  that  in
       restricted shells, redirections  which  can  create  files
       cannot be used.

       For  simple-commands,  redirections may appear anywhere in
       the command, for compound-commands (if statements,  etc.),
       any redirections must appear at the end.  Redirections are
       processed after pipelines are created  and  in  the  order
       they are given, so
              cat /foo/bar 2>>&1 >> /dev/null | cat -n
       will print an error with a line number prepended to it.

   Arithmetic Expressions
       Integer  arithmetic  expressions  can be used with the let
       command, inside $((..)) expressions, inside  array  refer-
       ences (e.g., name[expr]), as numeric arguments to the test
       command, and as the value of an assignment to  an  integer
       parameter.

       Expression  may  contain  alpha-numeric  parameter identi-
       fiers, array references, and integer constants and may  be
       combined  with  the  following  C  operators  (listed  and
       grouped in increasing order of precedence).

       Unary operators:
              + - ! ~ ++ --

       Binary operators:
              ,
              = *= /= %= += -= <<<<= >>>>= &= ^= |=
              ||
              &&
              |
              ^
              &
              == !=
              << <<= >>= >>
              <<<< >>>>
              + -
              * / %

       Ternary operator:
              ?: (precedence is immediately higher  than  assign-
              ment)

       Grouping operators:
              ( )

       Integer  constants  may  be specified with arbitrary bases
       using the notation base#number, where base  is  a  decimal
       integer specifying the base, and number is a number in the
       specified base.

       The operators are evaluated as follows:
              unary +
                     result is the argument  (included  for  com-
                     pleteness).
              unary -
                     negation.
              !      logical  not; the result is 1 if argument is
                     zero, 0 if not.
              ~      arithmetic (bit-wise) not.
              ++     increment; must be applied  to  a  parameter
                     (not  a  literal  or other expression) - the
                     parameter is incremented by 1.  When used as
                     a  prefix operator, the result is the incre-
                     mented value of the parameter, when used  as
                     a postfix operator, the result is the origi-
                     nal value of the parameter.
              ++     similar to ++, except the paramter is decre-
                     mented by 1.
              ,      seperates  two  arithmetic  expressions; the
                     left hand side is evaluated first, then  the
                     right.   The  result is value of the expres-
                     sion on the right hand side.
              =      assignment; variable on the left is  set  to
                     the value on the right.
              *= /= %= += -= <<<<= >>>>= &= ^= |=
                     assignment  operators; &lt;var> &lt;op>= &lt;expr> is
                     the same as &lt;var> = &lt;var> &lt;op> ( &lt;expr&gt; ).
              ||     logical or; the result is 1 if either  argu-
                     ment is non-zero, 0 if not.  The right argu-
                     ment is evaluated only if the left  argument
                     is zero.
              &&     logical  and;  the result is 1 if both argu-
                     ments are non-zero, 0  if  not.   The  right
                     argument is evaluated only if the left argu-
                     ment is non-zero.
              |      arithmetic (bit-wise) or.
              ^      arithmetic (bit-wise) exclusive-or.
              &      arithmetic (bit-wise) and.
              ==     equal; the result is 1 if both arguments are
                     equal, 0 if not.
              !=     not equal; the result is 0 if both arguments
                     are equal, 1 if not.
              <<      less than; the result is 1 if the left argu-
                     ment is less than the right, 0 if not.
              <<= >>= >>
                     less  than  or equal, greater than or equal,
                     greater than.  See <.
              <<<< >>>>  shift left (right); the result is  the  left
                     argument  with its bits shifted left (right)
                     by the amount given in the right argument.
              + - * /
                     addition, subtraction,  multiplication,  and
                     division.
              %      remainder;  the  result  is the remainder of
                     the division of the  left  argument  by  the
                     right.   The  sign of the result is unspeci-
                     fied if either argument is negative.
              &lt;arg1> ? &lt;arg2> : &lt;arg3>
                     if &lt;arg1> is non-zero, the result is &lt;arg2>,
                     otherwise &lt;arg3>.

   Co-Processes
       A  co-process,  which  is  a  pipeline created with the |&
       operator, is an asynchronous process that  the  shell  can
       both  write  to (using print -p) and read from (using read
       -p).  The input and output of the co-process can  also  be
       manipulated  using >>&p and <<&p redirections, respectively.
       Once a co-process  has  been  started,  another  can't  be
       started  until  the co-process exits, or until the co-pro-
       cess input has been redirected using an exec n>>&p redirec-
       tion.   If a co-process's input is redirected in this way,
       the next co-process to be started will  share  the  output
       with  the  first co-process, unless the output of the ini-
       tial co-process has been redirected  using  an  exec  n<<&p
       redirection.

       Some notes concerning co-processes:
         +o    the  only way to close the co-process input (so the
              co-process reads an end-of-file) is to redirect the
              input  to a numbered file descriptor and then close
              that file descriptor (e.g., exec 3>>&p;exec 3>>&-).
         +o    in order for co-processes to share a common output,
              the shell must keep the write portion of the output
              pipe open.  This means that end of file will not be
              detected until all co-processes sharing the co-pro-
              cess output have exited (when they  all  exit,  the
              shell  closes  its  copy of the pipe).  This can be
              avoided by redirecting the  output  to  a  numbered
              file  descriptor  (as this also causes the shell to
              close its  copy).   Note  that  this  behaviour  is
              slightly  different  from  the  original Korn shell
              which closes its copy of the write portion  of  the
              co-processs  output  when the most recently started
              co-process (instead of  when  all  sharing  co-pro-
              cesses) exits.
         +o    print  -p will ignore SIGPIPE signals during writes
              if the signal is not being trapped or ignored;  the
              same  is  not true if the co-process input has been
              duplicated to another file descriptor and print -un
              is used.

   Functions
       Functions  are  defined  using  either Korn shell function
       name syntax or the Bourne/POSIX shell name()  syntax  (see
       below  for  the  difference between the two forms).  Func-
       tions are like .-scripts in that they are executed in  the
       current  environment,  however,  unlike  .-scripts,  shell
       arguments (i.e.,  positional  parameters,  $1,  etc.)  are
       never  visible inside them.  When the shell is determining
       the location of a command, functions  are  searched  after
       special built-in commands, and before regular and non-reg-
       ular built-ins, and before the PATH is searched.

       An existing function may be deleted using unset  -f  func-
       tion-name.   A  list  of  functions  can be obtained using
       typeset +f and the  function  definitions  can  be  listed
       using typeset -f.  autoload (which is an alias for typeset
       -fu) may be used to create undefined  functions;  when  an
       undefined  function  is  executed,  the shell searches the
       path specified in the FPATH parameter for a file with  the
       same  name  as  the  function, which, if found is read and
       executed.  If after executing the file, the named function
       is  found  to be defined, the function is executed, other-
       wise, the normal command search is  continued  (i.e.,  the
       shell  searches  the  regular  built-in  command table and
       PATH).  Note that if a command is not found using PATH, an
       attempt  is  made to autoload a function using FPATH (this
       is an undocumented feature of the original Korn shell).

       Functions can have two attributes, trace and export, which
       can be set with typeset -ft and typeset -fx, respectively.
       When a traced function is  executed,  the  shell's  xtrace
       option  is turned on for the functions duration, otherwise
       the xtrace option is turned off.  The export attribute  of
       functions  is  currently  not  used.  In the original Korn
       shell, exported functions are  visible  to  shell  scripts
       that are executed.

       Since functions are executed in the current shell environ-
       ment, parameter  assignments  made  inside  functions  are

       visible  after the function completes.  If this is not the
       desired effect, the typeset command can be used  inside  a
       function  to  create a local parameter.  Note that special
       parameters (e.g., $$, $!) can't be scoped in this way.

       The exit status of a function is that of the last  command
       executed  in the function.  A function can be made to fin-
       ish immediately using the return command; this may also be
       used to explicitly specify the exit status.

       Functions  defined  with  the  function  reserved word are
       treated differently in the following ways  from  functions
       defined with the () notation:
         +o    the $0 parameter is set to the name of the function
              (Bourne-style functions leave $0 untouched).
         +o    parameter assignments preceeding function calls are
              not   kept  in  the  shell  environment  (executing
              Bourne-style functions will keep assignments).   In
              the  future, the following differences will also be
              added:
         +o    A separate trap/signal  environment  will  be  used
              during  the execution of functions.  This will mean
              that traps set inside a function  will  not  affect
              the  shell's traps and signals that are not ignored
              in the shell (but may be trapped) will  have  their
              default effect in a function.
         +o    The  EXIT  trap, if set in a function, will be exe-
              cuted after the function returns.

   POSIX Mode
       The shell is intended to be POSIX compliant,  however,  in
       some  cases,  POSIX  behaviour  is  contrary either to the
       original Korn shell behaviour or to user convenience.  How
       the  shell  behaves  in  these  cases is determined by the
       state of the posix option (set -o posix) -- if it  is  on,
       the POSIX behaviour is followed, otherwise it is not.  The
       posix option is set automatically when the shell starts up
       if the environment contains the POSIXLY_CORRECT parameter.
       (The shell can also be compiled so that  it  is  in  POSIX
       mode by default, however this is usually not desirable).

       The following is a list of things that are affected by the
       state of the posix option:
         +o    \" inside double quoted `..` command substitutions:
              in  posix mode, the \" is interpreted when the com-
              mand is interpreted; in non-posix mode,  the  back-
              slash  is  stripped before the command substitution
              is interpreted.  For example, echo "`echo  \"hi\"`"
              produces  `"hi"'  in  posix mode, `hi' in non-posix
              mode.  To avoid problems, use the $(...)   form  of
              command substitution.
         +o    kill  -l  output:  in  posix mode, signal names are
              listed one a single line; in non-posix mode, signal
              numbers,  names  and  descriptions  are  printed in
              columns.  In future, a new option (-v perhaps) will
              be added to distinguish the two behaviours.
         +o    fg exit status: in posix mode, the exit status is 0
              if no errors occur; in  non-posix  mode,  the  exit
              status is that of the last foregrounded job.
         +o    getopts:  in  posix mode, options must start with a
              -; in non-posix mode, options can start with either
              - or +.
         +o    brace  expansion  (also  known  as alternation): in
              posix mode, brace expansion is  disabled;  in  non-
              posix mode, brace expansion enabled.  Note that set
              -o posix (or setting the POSIXLY_CORRECT parameter)
              automatically  turns  the  braceexpand  option off,
              however it can be explicitly turned on later.
         +o    set -: in posix mode, this does not clear the  ver-
              bose or xtrace options; in non-posix mode, it does.
         +o    set exit status: in posix mode, the exit status  of
              set is 0 if there are no errors; in non-posix mode,
              the exit status is that of  any  command  substitu-
              tions performed in generating the set command.  For
              example, `set -- `false`;  echo  $?'  prints  0  in
              posix mode, 1 in non-posix mode.  This construct is
              used  in  most  shell  scripts  that  use  the  old
              getopt(1) command.
         +o    argument  expansion of alias, export, readonly, and
              typeset commands: in posix  mode,  normal  argument
              expansion done; in non-posix mode, field splitting,
              file globing, brace expansion  and  (normal)  tilde
              expansion  are  turned  off,  and  assignment tilde
              expansion is turned on.
         +o    signal specification: in posix mode, signals can be
              specified  as  digits  only if signal numbers match
              POSIX values (i.e., HUP=1, INT=2,  QUIT=3,  ABRT=6,
              KILL=9,  ALRM=14,  and TERM=15); in non-posix mode,
              signals can be always digits.
         +o    alias expansion: in posix mode, alias expansion  is
              only  carried  out  when  reading command words; in
              non-posix mode, alias expansion is carried  out  on
              any  word following an alias that ended in a space.
              For example, the following for loop
              alias a='for ' i='j'
              a i in 1 2; do echo i=$i j=$j; done
       uses parameter i in posix mode, j in non-posix mode.

   Command Execution
       After evaluation of command line  arguments,  redirections
       and  parameter  assignments, the type of command is deter-
       mined: a special built-in, a function, a regular  built-in
       or  the  name  of  a  file to execute found using the PATH
       parameter.  The checks are made in the above order.   Spe-
       cial  built-in commands differ from other commands in that
       the PATH parameter is not used to find them, an error dur-
       ing  their  execution can cause a non-interactive shell to
       exit and parameter assignments that are  specified  before

       the command are kept after the command completes.  Just to
       confuse things, if the posix option is turned off (see set
       command  below)  some special commands are very special in
       that no field splitting, file globing, brace expansion nor
       tilde  expansion  is preformed on arguments that look like
       assignments.  Regular built-in commands are different only
       in that the PATH parameter is not used to find them.

       The  original  ksh and POSIX differ somewhat in which com-
       mands are considered special or regular:

       POSIX special commands
              .          continue   exit       return     trap
              :          eval       export     set        unset
              break      exec       readonly   shift

       Additional ksh special commands
              builtin    times      typeset

       Very special commands (non-posix mode)
              alias      readonly   set        typeset

       POSIX regular commands
              alias      command    fg         kill       umask
              bg         false      getopts    read       unalias
              cd         fc         jobs       true       wait

       Additional ksh regular commands
              [          let        pwd        ulimit
              echo       print      test       whence

       In the future, the additional ksh special and regular com-
       mands  may  be  treated differently from the POSIX special
       and regular commands.

       Once the type of the command has been determined, any com-
       mand line parameter assignments are performed and exported
       for the duration of the command.

       The following describes the special and  regular  built-in
       commands:

       . file [arg1 ...]
              Execute  the  commands in file in the current envi-
              ronment.  The file is searched for in the  directo-
              ries  of  PATH.   If arguments are given, the posi-
              tional parameters may be used to access them  while
              file is being executed.  If no arguments are given,
              the positional parameters are those of the environ-
              ment the command is used in.

       : [ ... ]
              The null command.  Exit status is set to zero.

       alias [ -d | -t [-r] ] [-x] [name1[=value1] ...]
              Without  arguments,  alias  lists  all  aliases and
              their values.  For any name without  a  value,  its
              value  is listed.  Any name with a value defines an
              alias (see Aliases above).
              The -x option  sets  the  export  attribute  of  an
              alias, or, if no names are given, lists the aliases
              with the export attribute (exporting an alias  cur-
              rently has no affect).
              The -t option indicates that tracked aliases are to
              be listed/set (values specified on the command line
              are  ignored  for  tracked aliases).  The -r option
              indicates that all tracked aliases are to be reset.
              The  -d causes directory aliases, which are used in
              tilde expansion, to be listed  or  set  (see  Tilde
              Expansion above).

       bg [job ...]
              Resume  the  specified  stopped job(s) in the back-
              ground.  If no jobs are specified, %+  is  assumed.
              This  command  is  only  available on systems which
              support job control.  See  Job  Control  below  for
              more information.

       bind [-m] [key[=editing-command] ...]
              Set  or  view the current emacs command editing key
              bindings/macros.  See Emacs Interactive Input  Line
              Editing below for a complete description.

       break [level]
              break  exits  the  levelth  inner most for, select,
              until, or while loop.  level defaults to 1.

       builtin command [arg1 ...]
              Execute the built-in command command.

       cd [-LP] [dir]
              Set the working directory to dir.  If the parameter
              CDPATH  is  set,  it  lists the search path for the
              directory containing dir.  A null  path  means  the
              current  directory.   If  dir  is missing, the home
              directory $HOME is used.  If dir is -, the previous
              working  directory  is used (see OLDPWD parameter).
              If -L option (logical path) is used or if the phys-
              ical option (see set command below) isn't set, ref-
              erences to .. in dir are relative to the path  used
              get to the directory.  If -P option (physical path)
              is used or if the physical option  is  set,  ..  is
              relative to the filesystem directory tree.  The PWD
              and OLDPWD parameters are updated  to  reflect  the
              current and old wording directory, respectively.

       cd [-LP] old new
              The  string  new is substituted for old in the cur-
              rent directory, and the shell attempts to change to
              the new directory.

       command [-pvV] cmd [arg1 ...]
              If  neither the -v nor -V options are given, cmd is
              executed exactly as if the  command  had  not  been
              specified,  with  two exceptions: first, cmd cannot
              be a shell function, and second,  special  built-in
              commands  lose their specialness (i.e., redirection
              and utility errors do not cause the shell to  exit,
              and command assignments are not permanent).  If the
              -p option is given, a default search path  is  used
              instead  of  the  current value of PATH (the actual
              value of the default path is system  dependent:  on
              POSIXish systems, it is the value returned by
                                getconf CS_PATH
              ).
              If  the  -v  option  is given, instead of executing
              cmd, information about what would  be  executed  is
              given (and the same is done for arg1 ...): for spe-
              cial and regular built-in commands  and  functions,
              their names are simply printed, for aliases, a com-
              mand that defines them is printed, and for commands
              found  by  searching  the  PATH parameter, the full
              path of the command is printed.  If no  command  is
              be found, (i.e., the path search fails), nothing is
              printed and command exits with a  non-zero  status.
              The  -V  option is like the -v option, except it is
              more verbose.

       continue [levels]
              continue jumps to  the  beginning  of  the  levelth
              inner  most  for,  select,  until,  or  while loop.
              level defaults to 1.

       echo [-neE] [arg ...]
              Prints its arguments (separated by spaces) followed
              by a newline, to standard out.  The newline is sup-
              pressed if any of the arguments contain  the  back-
              slash  sequence  \c.  See print command below for a
              list of other backslash sequences that  are  recog-
              nized.
              The options are provided for compatibility with BSD
              shell scripts: -n suppresses the trailing  newline,
              -e enables backslash interpretation (a no-op, since
              this is normally done),  and  -E  which  suppresses
              backslash interpretation.

       eval command ...
              The arguments are concatenated (with spaces between
              them) to form a single string which the shell  then
              parses and executes in the current environment.

       exec [command [arg ...]]
              The  command is executed without forking, replacing
              the shell process.
              If no arguments are given, any  IO  redirection  is
              permanent  and the shell is not replaced.  Any file
              descriptors greater than  2  which  are  opened  or
              dup(2)-ed  in  this  way  are not made available to
              other executed commands (i.e.,  commands  that  are
              not built-in to the shell).

       exit [status]
              The shell exits with the specified exit status.  If
              status is not specified, the  exit  status  is  the
              current value of the ? parameter.

       export [-p] [parameter[=value]] ...
              Sets  the export attribute of the named parameters.
              Exported parameters are passed in  the  environment
              to executed commands.  If values are specified, the
              named parameters also assigned.
              If no parameters are specified, the  names  of  all
              parameters  with  the  export attribute are printed
              one per line, unless the  -p  option  is  used,  in
              which  case  export  commands defining all exported
              parameters, including their values, are printed.

       false  A command that exits with a non-zero status.

       fc [-e editor | -l [-n]] [-r] [first [last]]
              first and last select commands  from  the  history.
              Commands  can  be  selected by history number, or a
              string specifying the most recent command  starting
              with  that string.  The -l option lists the command
              on stdout, and -n inhibits the default command num-
              bers.   The  -r  option  reverses  the order of the
              list.  Without -l, the selected commands are edited
              by  the  editor specified with the -e option, or if
              no -e is specified, the  editor  specified  by  the
              FCEDIT  parameter  (if  this  parameter is not set,
              /bin/ed is used), and then executed by the shell.

       fc [-e - | -s] [-g] [old=new] [prefix]
              Re-execute the selected command (the previous  com-
              mand by default) after performing the optional sub-
              stitution of old with new.  If -g is specified, all
              occurrences  of  old  are  replaced with new.  This
              command is usually  accessed  with  the  predefined
              alias r='fc -e -'.

       fg [job ...]
              Resume  the specified job(s) in the foreground.  If
              no jobs are specified, %+ is assumed.  This command
              is only available on systems which support job con-
              trol.  See Job Control below for more  information.

       getopts optstring name [arg ...]
              getopts  is  used  by shell procedures to parse the
              specified arguments (or positional  parameters,  if
              no  arguments  are  given)  and  to check for legal
              options.  optstring  contains  the  option  letters
              that  getopts is to recognize.  If a letter is fol-
              lowed by a colon, the option is expected to have an
              argument.   Arguments  containing  options must all
              start with either a - or a +, options that  do  not
              take arguments may be grouped in a single argument.
              If an option takes an argument and the option char-
              acter  is not the last character of the argument it
              is found in, the remainder of the argument is taken
              to  be  the  option's argument, otherwise, the next
              argument is the option's argument.
              Each time getopts is invoked, it  places  the  next
              option in the shell parameter name and the index of
              the next argument to  be  processed  in  the  shell
              parameter  OPTIND.   If  the  option was introduced
              with a +, the option placed  in  name  is  prefixed
              with  a  +.   When  an option requires an argument,
              getopts places it in the  shell  parameter  OPTARG.
              When an illegal option or a missing option argument
              is encountered a question mark or a colon is placed
              in  name  (indicating  an illegal option or missing
              argument, respectively) and OPTARG is  set  to  the
              option character that caused the problem.  An error
              message is also printed to standard error  if  opt-
              string does not begin with a colon.
              When the end of the options is encountered, getopts
              exits with a non-zero exit status.  Options end  at
              the  first (non-option argument) argument that does
              not start with a  -,  or  when  a  --  argument  is
              encountered.
              Option  parsing can be reset by setting OPTIND to 1
              (this is done automatically whenever the shell or a
              shell procedure is invoked).
              Warning:  Changing the value of the shell parameter
              OPTIND to a value other than 1, or parsing  differ-
              ent  sets of arguments without resetting OPTIND may
              lead to unexpected results.

       hash [-r] [name ...]
              Without arguments, any  hashed  executable  command
              pathnames  are  listed.   The  -r option causes all
              hashed commands to be removed from the hash  table.
              Each name is searched as if it where a command name
              and added to the hash table if it is an  executable
              command.

       jobs [-lpn] [job ...]
              Display information about the specified jobs; if no
              jobs are specified, all jobs are displayed.  The -n
              option  causes information to be displayed only for
              jobs that have changed state since the last notifi-
              cation.   If  the -l option is used, the process-id
              of each process in a job is also  listed.   The  -p
              option causes only the process group of each job to
              be printed.  See Job Control below for  the  format
              of job and the displayed job.

       kill [-s signame | -signum | -signame ] { job | pid |
              -pgrp } ...
              Send  the  specified  signal to the specified jobs,
              process ids, or process groups.  If  no  signal  is
              specified,  the  signal  TERM is sent.  If a job is
              specified, the signal is sent to the job's  process
              group.   See  Job  Control  below for the format of
              job.

       kill -l [exit-status ...]
              Print the name of the signal that killed a  process
              which  exited with the specified exit-statuses.  If
              no arguments are specified, a list of all the  sig-
              nals, their numbers and a short description of them
              are printed.

       let [expression ...]
              Each  expression  is  evaluated,   see   Arithmetic
              Expressions above.  If all expressions are success-
              fully evaluated, the exit status is 0  (1)  if  the
              last  expression  evaluated to non-zero (zero).  If
              an error occurs during the parsing or evaluation of
              an  expression,  the exit status is greater than 1.
              Since expressions may need to be quoted, (( expr ))
              is syntactic sugar for let "expr".

       print [-nprsun | -R [-en]] [argument ...]
              Print  prints its arguments on the standard output,
              separated by spaces, and terminated with a newline.
              The  -n option suppresses the newline.  By default,
              certain C escapes are  translated.   These  include
              \b,  \f,  \n,  \r, \t, \v, and \0### (# is an octal
              digit, of which there may be 0 to 3).  \c is equiv-
              alent  to  using the -n option.  \ expansion may be
              inhibited with the -r option.  The -s option prints
              to the history file instead of standard output, the
              -u option prints to file descriptor n  (n  defaults
              to  1  if omitted), and the -p option prints to the
              co-process (see Co-Processes above).
              The -R option is used to emulate, to  some  degree,
              the  BSD  echo  command,  which  does not process \
              sequences unless the -e option is given.  As above,
              the -n option suppresses the trailing newline.

       pwd [-LP]
              Print  the present working directory.  If -L option
              is used or if the physical option (see set  command
              below)  isn't  set,  the  logical  path  is printed
              (i.e., the path used to cd to  the  current  direc-
              tory).   If -P option (physical path) is used or if
              the physical option is  set,  the  path  determined
              from  the  filesystem (by following ..  directories
              to the root directory) is printed.

       read [-prsun] [parameter ...]
              Reads a line of input from standard input, separate
              the  line  into fields using the IFS parameter (see
              Substitution above), and assign each field  to  the
              specified parameters.  If there are more parameters
              than fields, the extra parameters are set to  null,
              or  alternatively,  if  there  are more fields than
              parameters, the  last  parameter  is  assigned  the
              remaining   fields  (inclusive  of  any  separating
              spaces).  If no parameters are specified, the REPLY
              parameter  is  used.   If  the input line ends in a
              backslash and the -r option was not used, the back-
              slash  and  newline  are stripped and more input is
              read.  If no input is read, read exits with a  non-
              zero status.
              The  first parameter may have a question mark and a
              string appended to it, in which case the string  is
              used  as a prompt (printed to standard error before
              any input is read) if the input  is  a  tty  (e.g.,
              read nfoo?'number of foos: ').
              The  -un and -p options cause input to be read from
              file descriptor n or the  current  co-process  (see
              Co-Processes  above  for comments on this), respec-
              tively.  If the -s option is used, input  is  saved
              to the history file.

       readonly [-p] [parameter[=value]] ...
              Sets  the  readonly  attribute of the named parame-
              ters.  If values are given, parameters are  set  to
              them  before setting the attribute.  Once a parame-
              ter is made readonly, it cannot be  unset  and  its
              value cannot be changed.
              If  no  parameters  are specified, the names of all
              parameters with the readonly attribute are  printed
              one  per  line,  unless  the  -p option is used, in
              which case readonly commands defining all  readonly
              parameters, including their values, are printed.

       return [status]
              Returns from a function or . script, with exit sta-
              tus status.  If no status is given, the exit status
              of the last executed command is used.  If used out-
              side of a function or . script,  it  has  the  same
              effect  as  exit.  Note that pdksh treats both pro-
              file and $ENV files as . scripts, while the  origi-
              nal Korn shell only treats profiles as . scripts.

       set  [+-abCefhkmnpsuvxX] [+-o [option]] [+-A name] [--]
              [arg ...]
              The set command can be used to set (-) or clear (+)
              shell options, set the  positional  parameters,  or
              set  an  array  parameter.   Options can be changed
              using the +-o option syntax, where  option  is  the
              long  name of an option, or using the +-letter syn-
              tax, where letter is  the  option's  single  letter
              name  (not  all options have a single letter name).
              The following table lists both option  letters  (if
              they exist) and long names along with a description
              o