1 KSH93(1)                         User Commands                        KSH93(1)
   2 
   3 
   4 
   5 NAME
   6        ksh93, rksh93 - Korn Shell, a standard and restricted command and
   7        programming language
   8 
   9 SYNOPSIS
  10        ksh93 [+-abcefhikmnoprstuvxBCD] [-R file] [ +-o option] ...
  11               [-] [arg ...]
  12 
  13 
  14        rksh93 [+-abcefhikmnoprstuvxBCD] [-R file] [+-o option] ...
  15               [-] [arg ...]
  16 
  17 
  18 DESCRIPTION
  19        ksh93 is a command and programming language that executes commands read
  20        from a terminal or a file. rksh93 is a restricted version of the
  21        command interpreter ksh93. rksh93 is used to set up login names and
  22        execution environments whose capabilities are more controlled than
  23        those of the standard shell.
  24 
  25 
  26        See Invocation for the meaning of arguments to the shell.
  27 
  28    Definitions
  29        A metacharacter is defined as one of the following characters:
  30 
  31          ; & ( ) | < > NEWLINE SPACE TAB
  32 
  33 
  34 
  35 
  36        A blank is a TAB or a SPACE.
  37 
  38 
  39        An identifier is a sequence of letters, digits, or underscores starting
  40        with a letter or underscore. Identifiers are used as components of
  41        variable names.
  42 
  43 
  44        A vname is a sequence of one or more identifiers separated by a period
  45        (.) and optionally preceded by a period (.). vnames are used as
  46        function and variable names.
  47 
  48 
  49        A word is a sequence of characters from the character set defined by
  50        the current locale, excluding non-quoted metacharacters.
  51 
  52 
  53        A command is a sequence of characters in the syntax of the shell
  54        language. The shell reads each command and carries out the desired
  55        action either directly or by invoking separate utilities. A built-in
  56        command is a command that is carried out by the shell itself without
  57        creating a separate process. Some commands are built-in purely for
  58        convenience and are not documented in this manual page. Built-ins that
  59        cause side effects in the shell environment and built-ins that are
  60        found before performing a path search (see Execution) are documented in
  61        this manual page. For historical reasons, some of these built-ins
  62        behave differently than other built-ins and are called special built-
  63        ins.
  64 
  65    Commands
  66        A simple-command is a list of variable assignments (see Variable
  67        Assignments) or a sequence of blank-separated words which can be
  68        preceded by a list of variable assignments. See the Environment section
  69        of this manual page.
  70 
  71 
  72        The first word specifies the name of the command to be executed. Except
  73        as specified in this section, the remaining words are passed as
  74        arguments to the invoked command. The command name is passed as
  75        argument 0. See exec(2).  The value of a simple-command is its exit
  76        status. If it terminates normally, its value is 0-255. If it terminates
  77        abnormally, its value is 256+signum. The name of the signal
  78        corresponding to the exit status can be obtained by way of the -l
  79        option of the kill built-in utility.
  80 
  81 
  82        A pipeline is a sequence of one or more commands separated by |.  The
  83        standard output of each command but the last is connected by a pipe(2)
  84        to the standard input of the next command. Each command, except
  85        possibly the last, is run as a separate process. The shell waits for
  86        the last command to terminate. The exit status of a pipeline is the
  87        exit status of the last command unless the pipefail option is enabled.
  88        Each pipeline can be preceded by the reserved word!. This causes the
  89        exit status of the pipeline to become 0 if the exit status of the last
  90        command is non-zero, and 1 if the exit status of the last command is 0.
  91 
  92 
  93        A list is a sequence of one or more pipelines separated by ;, &,     |&,
  94        &&, or |, and optionally terminated by ;, &, or |&. Of these five
  95        symbols, ;, &, and |& have equal precedence, which is lower than that
  96        of && and ||. The symbols && and || also have equal precedence.
  97 
  98 
  99        A semicolon (;) causes sequential execution of the preceding pipeline.
 100        An ampersand (&)     causes asynchronous execution of the preceding
 101        pipeline, that is, the shell does not wait for that pipeline to finish.
 102        The symbol |& causes asynchronous execution of the preceding pipeline
 103        with a two-way pipe established to the parent shell. The standard input
 104        and output of the spawned pipeline can be written to and read from by
 105        the parent shell by applying the redirection operators <& and >&   with
 106        arg p to commands and by using -p option of the built-in commands read
 107        and print. The symbol && (||) causes the list following it to be
 108        executed only if the preceding pipeline returns a zero (non-zero)
 109        value. One or more NEWLINEs can appear in a list instead of a
 110        semicolon, to delimit a command. The first item of the first pipeline
 111        of a list that is a simple command not beginning with a redirection,
 112        and not occurring within a while, until, or if list , can be preceded
 113        by a semicolon. This semicolon is ignored unless the showme option is
 114        enabled as described with the set built-in.
 115 
 116 
 117        A command is either a simple-command or one of commands in the
 118        following list. Unless otherwise stated, the value returned by a
 119        command is that of the last simple-command executed in the command.
 120 
 121        for vname [ in word ... ] ;do list ;done
 122 
 123            Each time a for command is executed, vname is set to the next word
 124            taken from the in word list. If in word ... is omitted, the for
 125            command executes the do list once for each positional parameter
 126            that is set starting from 1. Execution ends when there are no more
 127            words in the list. See Parameter Expansion.
 128 
 129 
 130        for (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done
 131 
 132            The arithmetic expression expr1 is evaluated first. The arithmetic
 133            expression expr2 is repeatedly evaluated until it evaluates to zero
 134            and when non-zero, list is executed and the arithmetic expression
 135            expr3 evaluated. If any expression is omitted, then it behaves as
 136            if it evaluated to 1. See Arithmetic Evaluation.
 137 
 138 
 139        select vname [ in word ... ] ;do list ;done
 140 
 141            A select command prints on standard error (file descriptor 2) the
 142            set of words, each preceded by a number. If in word... is omitted,
 143            the positional parameters starting from 1 are used instead. See
 144            Parameter Expansion. The PS3 prompt is printed and a line is read
 145            from the standard input. If this line consists of the number of one
 146            of the listed words, then the value of the variable vname is set to
 147            the word corresponding to this number. If this line is empty, the
 148            selection list is printed again. Otherwise the value of the
 149            variable vname is set to null. The contents of the line read from
 150            standard input is saved in the variable REPLY. The list is executed
 151            for each selection until a break or EOF is encountered. If the
 152            REPLY variable is set to null by the execution of list, the
 153            selection list is printed before displaying the PS3 prompt for the
 154            next selection.
 155 
 156 
 157        case word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
 158 
 159            A case command executes the list associated with the first pattern
 160            that matches word. The form of the patterns is the same as that
 161            used for file name generation. See File Name Generation.
 162 
 163            The ;; operator causes execution of case to terminate. If ;&     is
 164            used in place of ;; the next subsequent list, if any, is executed.
 165 
 166 
 167        if list ;then list [ ;elif list ;then list ] ... [ ;else list ] ;fi
 168 
 169            The list following if is executed and, if it returns a zero exit
 170            status, the list following the first then is executed.  Otherwise,
 171            the list following elif is executed, and, if its value is zero, the
 172            list following the next then is executed.  Failing each successive
 173            elif list, the else list is executed. If the if list has non-zero
 174            exit status and there is no else list, then the if command returns
 175            a zero exit status.
 176 
 177 
 178        while list ;do list ;done
 179        until list ;do list ;done
 180 
 181            A while command repeatedly executes the while list and, if the exit
 182            status of the last command in the list is zero, executes the do
 183            list, otherwise the loop terminates. If no commands in the do list
 184            are executed, then the while command returns a zero exit status,
 185            until can be used in place of while to negate the loop termination
 186            test.
 187 
 188 
 189        ((expression))
 190 
 191            The expression is evaluated using the rules for arithmetic
 192            evaluation described in this manual page. If the value of the
 193            arithmetic expression is non-zero, the exit status is 0. Otherwise
 194            the exit status is 1.
 195 
 196 
 197        (list)
 198 
 199            Execute list in a separate environment. If two adjacent open
 200            parentheses are needed for nesting, a SPACE must be inserted to
 201            avoid evaluation as an arithmetic command as described in this
 202            section.
 203 
 204 
 205        { list;}
 206 
 207            list is simply executed. Unlike the metacharacters, ( and ), { and
 208            } are reserved words and must occur at the beginning of a line or
 209            after a ; to be recognized.
 210 
 211 
 212        [[ expression ]]
 213 
 214            Evaluates expression and returns a zero exit status when expression
 215            is true. See Conditional Expressions for a description of
 216            expression.
 217 
 218 
 219        function varname { list ;}
 220        varname () { list ;}
 221 
 222            Define a function which is referenced by varname. A function whose
 223            varname contains a dot (.) is called a discipline function and the
 224            portion of the varname preceding the last . must refer to an
 225            existing variable.
 226 
 227            The body of the function is the list of commands between { and }. A
 228            function defined with the function varname syntax can also be used
 229            as an argument to the . special built-in command to get the
 230            equivalent behavior as if the varname() syntax were used to define
 231            it. See Functions.
 232 
 233 
 234        namespace identifier { list };
 235 
 236            Defines or uses the name space identifier and runs the commands in
 237            list in this name space.  See Name Spaces.
 238 
 239 
 240        time [ pipeline ]
 241 
 242            If pipeline is omitted, the user and system time for the current
 243            shell and completed child processes is printed on standard error.
 244            Otherwise, pipeline is executed and the elapsed time as well as the
 245            user and system time are printed on standard error. The TIMEFORMAT
 246            variable can be set to a format string that specifies how the
 247            timing information should be displayed.  See Shell Variables for a
 248            description of the TIMEFORMAT variable.
 249 
 250 
 251 
 252        The following reserved words are recognized as reserved only when they
 253        are the first word of a command and are not quoted:
 254 
 255          case
 256          do
 257          done
 258          else
 259          elif
 260          esac
 261          for
 262          fi
 263          function
 264          if
 265          select
 266          then
 267          time
 268          until
 269          while
 270          { }
 271          [[ ]]
 272          !
 273 
 274    Variable Assignments
 275        One or more variable assignments can start a simple command or can be
 276        arguments to the typeset, enum, export, or readonly special built-in
 277        commands. The syntax for an assignment is of the form:
 278 
 279        varname=word
 280        varname[word]=word
 281 
 282            No space is permitted between varname and the = or between = and
 283            word.  The variable varname is unset before the assignment.
 284 
 285 
 286        varname=(assignlist)
 287 
 288            No space is permitted between varname and the =. An assignlist can
 289            be one of the following:
 290 
 291            word ...
 292 
 293                Indexed array assignment.
 294 
 295 
 296            [word]=word ...
 297 
 298                Associative array assignment. If prefixed by typeset -a,
 299                creates an indexed array instead.
 300 
 301 
 302            assignment ...
 303 
 304                Compound variable assignment. This creates a compound variable
 305                varname with sub-variables of the form varname.name, where name
 306                is the name portion of assignment. The value of varname
 307                contains all the assignment elements. Additional assignments
 308                made to sub-variables of varname are also displayed as part of
 309                the value of varname. If no assignments are specified, varname
 310                is a compound variable allowing subsequence child elements to
 311                be defined.
 312 
 313 
 314            typeset [options] assignment ...
 315 
 316                Nested variable assignment. Multiple assignments can be
 317                specified by separating each of them with a ;. The previous
 318                value is unset before the assignment.
 319 
 320 
 321            . filename
 322 
 323                Include the assignment commands contained in filename.
 324 
 325            In addition, a += can be used in place of the = to signify adding
 326            to or appending to the previous value. When += is applied to an
 327            arithmetic type, word is evaluated as an arithmetic expression and
 328            added to the current value. When applied to a string variable, the
 329            value defined by word is appended to the value. For compound
 330            assignments, the previous value is not unset and the new values are
 331            appended to the current ones provided that the types are
 332            compatible.
 333 
 334            The right hand side of a variable assignment undergoes all the
 335            expansion listed below except word splitting, brace expansion, and
 336            file name generation.  When the left hand side is an assignment is
 337            a compound variable and the right hand is the name of a compound
 338            variable, the compound variable on the right will be copied or
 339            appended to the compound variable on the left.
 340 
 341 
 342 
 343    Comments
 344        A word beginning with # causes that word and all the following
 345        characters up to a NEWLINE to be commented, or ignored.
 346 
 347    Aliasing
 348        The first word of each command is replaced by the text of an alias if
 349        an alias for this word has been defined. An alias name consists of any
 350        number of characters excluding metacharacters, quoting characters, file
 351        expansion characters, parameter expansion characters, command
 352        substitution characters, the characters / and =. The replacement string
 353        can contain any valid shell script including the metacharacters listed
 354        in the Commands section. The first word of each command in the replaced
 355        text, other than any that are in the process of being replaced, are
 356        tested for aliases. If the last character of the alias value is a BLANK
 357        then the word following the alias is also checked for alias
 358        substitution.
 359 
 360 
 361        Aliases can be used to redefine built-in commands but cannot be used to
 362        redefine the reserved words listed in the Commands section. Aliases can
 363        be created and listed with the alias command and can be removed with
 364        the unalias command.
 365 
 366 
 367        Aliasing is performed when scripts are read, not while they are
 368        executed. For an alias to take effect, the alias definition command has
 369        to be executed before the command which references the alias is read.
 370        The following aliases are compiled into the shell but can be unset or
 371        redefined:
 372 
 373          autoload='typeset -fu'
 374          command='command '
 375          compound='typeset -C'
 376          fc=hist
 377          float='typeset -lE'
 378          functions='typeset -f'
 379          hash='alias -t --'
 380          history='hist -l'
 381          integer='typeset -li'
 382          nameref='typeset -n'
 383          nohup='nohup '
 384          r='hist -s'
 385          redirect='command exec'
 386          source='command .'
 387          stop='kill -s STOP'
 388          suspend='kill -s STOP $$'
 389          times='{ { time;} 2>&1;}'
 390          type='whence -v'
 391 
 392 
 393 
 394    Tilde Substitution
 395        After alias substitution is performed, each word is checked to see if
 396        it begins with an unquoted tilde (~). For tilde substitution, word also
 397        refers to the word portion of parameter expansion. See Parameter
 398        Expansion.
 399 
 400 
 401        If it does, the word up to a / is checked to see if it matches a user
 402        name in the password database. If a match is found, the ~ and the
 403        matched login name are replaced by the login directory of the matched
 404        user. If no match is found, the original text is left unchanged. A ~ by
 405        itself, or in front of a /, is replaced by $HOME. A ~ followed by a +
 406        or - is replaced by the value of $PWD and $OLDPWD respectively.
 407 
 408 
 409        In addition, when expanding a variable assignment, tilde substitution
 410        is attempted when the value of the assignment begins with a ~, and when
 411        a ~ appears after a colon (:). The : also terminates a ~ login name.
 412 
 413    Command Substitution
 414        The standard output from a command enclosed in parentheses preceded by
 415        a dollar sign ( $(list) ), or in a brace group preceded by a dollar
 416        sign ( ${ list;} ), or in a pair of grave accents (``) can be used as
 417        part or all of a word. Trailing NEWLINEs are removed. In the second
 418        case, the { and } are treated as a reserved words so that { must be
 419        followed by a blank and } must appear at the beginning of the line or
 420        follow a ;. In the third (obsolete) form, the string between the quotes
 421        is processed for special quoting characters before the command is
 422        executed. See Quoting.
 423 
 424 
 425        The command substitution $(cat file) can be replaced by the equivalent
 426        but faster $(<file). The      command substitution $(n<#) expands to the
 427        current byte offset for file descriptor n. Except for the second form,
 428        the command list is run in a subshell so that no side effects are
 429        possible. For the second form, the final } will be recognized as a
 430        reserved word after any token.
 431 
 432    Arithmetic Substitution
 433        An arithmetic expression enclosed in double parentheses preceded by a
 434        dollar sign ( $((arithmetic_expression))) is replaced by the value of
 435        the arithmetic expression within the double parentheses.
 436 
 437    Process Substitution
 438        Each command argument of the form <(list) or >(list) runs process list
 439        asynchronously connected to some file in /dev/fd. The name of this file
 440        becomes the argument to the command. If the form with > is selected
 441        then writing on this file provides input for list. If < is used,      then
 442        the file passed as an argument contains the output of the list process.
 443 
 444 
 445        For example,
 446 
 447          paste <(cut -f1 file1)      <(cut -f3 file2) | tee \
 448               >(process1) >(process2)
 449 
 450 
 451 
 452 
 453        cuts fields 1 and 3 from the files file1 and file2 respectively, pastes
 454        the results together, and sends it to the processes process1 and
 455        process2. It also displays the results to the standard output. The
 456        file, which is passed as an argument to the command, is a UNIX pipe(2).
 457        Programs that expect to lseek(2) on the file do not work.
 458 
 459        Process substitution of the form <(list)      can also be used with the <
 460        redirection operator which causes the output of list to be standard
 461        input or the input for whatever file descriptor is specified.
 462 
 463    Parameter Expansion
 464        A parameter is a variable, one or more digits, or any of the characters
 465        *, @, #, ?, -, $, and !. A variable is denoted by a vname. To create a
 466        variable whose vname contains a ., a variable whose vname consists of
 467        everything before the last . must already exist. A variable has a value
 468        and zero or more attributes.  Variables can be assigned values and
 469        attributes by using the typeset special built-in command. The
 470        attributes supported by the shell are described later with the typeset
 471        special built-in command. Exported variables pass values and attributes
 472        to the environment.
 473 
 474 
 475        The shell supports both indexed and associative arrays. An element of
 476        an array variable is referenced by a subscript. A subscript for an
 477        indexed array is denoted by an arithmetic expression, (see Arithmetic
 478        Evaluation), between a [ and a ].  To assign values to an indexed
 479        array, use vname=(value ...) or set -A vname value ... .  The value of
 480        all subscripts must be in the range of 0 through 4,194,303. A negative
 481        subscript is treated as an offset from the maximum current index +1 so
 482        that -1 refers to the last element.  Indexed arrays can be declared
 483        with the -a option to typeset. Indexed arrays need not be declared. Any
 484        reference to a variable with a valid subscript is legal and an array
 485        will be created if necessary.
 486 
 487 
 488        An associative array is created with the -A option to typeset. A
 489        subscript for an associative array is denoted by a string enclosed
 490        between [ and ].
 491 
 492 
 493        Referencing any array without a subscript is equivalent to referencing
 494        the array with subscript 0.
 495 
 496 
 497        The value of a variable can be assigned by:
 498 
 499          vname=value [vname=value] ...
 500 
 501 
 502 
 503 
 504        or
 505 
 506          vname[subscript]=value [vname[subscript]=value] ...
 507 
 508        Note that no space is allowed before or after the =.
 509 
 510        Attributes assigned by the typeset special built-in command apply to
 511        all elements of the array.  An array element can be a simple variable,
 512        a compound variable or an array variable.  An element of an indexed
 513        array can be either an indexed array or an associative array.  An
 514        element of an associative array can also be either.  To refer to an
 515        array element that is part of an array element, concatenate the
 516        subscript in brackets.  For example, to refer to the foobar element of
 517        an associative array that is defined as the third element of the
 518        indexed array, use ${vname[3][foobar]}
 519 
 520 
 521        A nameref is a variable that is a reference to another variable. A
 522        nameref is created with the -n attribute of typeset. The value of the
 523        variable at the time of the typeset command becomes the variable that
 524        is referenced whenever the nameref variable is used. The name of a
 525        nameref cannot contain a dot (.). When a variable or function name
 526        contains a dot (.) and the portion of the name up to the first .
 527        matches the name of a nameref, the variable referred to is obtained by
 528        replacing the nameref portion with the name of the variable referenced
 529        by the nameref. If a nameref is used as the index of a for loop, a name
 530        reference is established for each item in the list. A nameref provides
 531        a convenient way to refer to the variable inside a function whose name
 532        is passed as an argument to a function. For example, if the name of a
 533        variable is passed as the first argument to a function, the command
 534 
 535           typeset -n var=$1
 536 
 537 
 538 
 539 
 540        inside the function causes references and assignments to var to be
 541        references and assignments to the variable whose name has been passed
 542        to the function. If any of the floating point attributes, -E,-F or -X,
 543        or the integer attribute, -i, is set for vname, then the value is
 544        subject to arithmetic evaluation as described in this manual page.
 545        Positional parameters, parameters denoted by a number, can be assigned
 546        values with the set special built-in command. Parameter $0 is set from
 547        argument zero when the shell is invoked.
 548 
 549        The character $ is used to introduce substitutable parameters.
 550 
 551        ${parameter}
 552 
 553            The shell reads all the characters from ${ to the matching } as
 554            part of the same word even if it contains braces or metacharacters.
 555            The value, if any, of the parameter is substituted. The braces are
 556            required when parameter is followed by a letter, digit, or
 557            underscore that is not to be interpreted as part of its name or
 558            when the variable name contains a dot (.). The braces are also
 559            required when a variable is subscripted unless it is part of an
 560            Arithmetic Expression or a Conditional Expression. If parameter is
 561            one or more digits then it is a positional parameter. A positional
 562            parameter of more than one digit must be enclosed in braces. If
 563            parameter is * or @, then all the positional parameters, starting
 564            with $1, are substituted and separated by a field separator
 565            character. If an array vname with last subscript * or @ is used, or
 566            for index arrays of the form sub1 .. sub2 is used, then the value
 567            for each of the elements between sub1 and sub2 inclusive (or all
 568            elements for * and @) is substituted, separated by the first
 569            character of the value of IFS.
 570 
 571 
 572        ${#parameter}
 573 
 574            If parameter is * or @, the number of positional parameters is
 575            substituted. Otherwise, the length of the value of the parameter is
 576            substituted.
 577 
 578 
 579        ${#vname[*]}
 580        ${#vname[@]}
 581 
 582            The number of elements in the array vname is substituted.
 583 
 584        ${@vname}
 585 
 586            Expands to the type name or attributes of the variable referred to
 587            by vname. See Type Variables.
 588 
 589 
 590        ${!vname}
 591 
 592            Expands to the name of the variable referred to by vname. This is
 593            vname except when vname is a name reference.
 594 
 595 
 596        ${!vname[subscript]}
 597 
 598            Expands to name of the subscript unless subscript is * or @, or of
 599            the form sub1 .. sub2.  When subscript is *, the list of array
 600            subscripts for vname is generated. For a variable that is not an
 601            array, the value is 0 if the variable is set, otherwise it is null.
 602            When subscript is @, it is the same as $ {vname[*]}, except that
 603            when used in double quotes, each array subscript yields a separate
 604            argument.  When subscript is of the form sub1 .. sub2 it expands to
 605            the list of subscripts between sub1 and sub2 inclusive using the
 606            same quoting rules as @.
 607 
 608 
 609        ${!prefix*}
 610 
 611            Expands to the names of the variables whose names begin with
 612            prefix.
 613 
 614 
 615        ${parameter:-word}
 616 
 617            If parameter is set and is non-null then substitute its value.
 618            Otherwise substitute word.
 619 
 620 
 621        ${parameter:=word}
 622 
 623            If parameter is not set or is null, set it to word. The value of
 624            the parameter is then substituted. Positional parameters cannot be
 625            assigned to in this way.
 626 
 627 
 628        ${parameter:?word}
 629 
 630            If parameter is set and is non-null, substitute its value.
 631            Otherwise, print word and exit from the shell , if the shell is not
 632            interactive. If word is omitted then a standard message is printed.
 633 
 634 
 635        ${parameter:+word}
 636 
 637            If parameter is set and is non-null, substitute word. Otherwise
 638            substitute nothing.
 639 
 640        In the above, word is not evaluated unless it is to be used as the
 641        substituted string. In the following example, pwd is executed only if d
 642        is not set or is NULL:
 643 
 644          print ${d:-$(pwd)}
 645 
 646 
 647        If the colon (:) is omitted from the expression, the shell only checks
 648        whether parameter is set or not.
 649 
 650 
 651        ${parameter:offset:length}
 652        ${parameter:offset}
 653 
 654            Expands to the portion of the value of parameter starting at the
 655            character (counting from 0) determined by expanding offset as an
 656            arithmetic expression and consisting of the number of characters
 657            determined by the arithmetic expression defined by length.
 658 
 659            In the second form, the remainder of the value is used. A negative
 660            offset counts backwards from the end of parameter.
 661 
 662            One or more BLANKs is required in front of a minus sign to prevent
 663            the shell from interpreting the operator as :-. If parameter is *
 664            or @, or is an array name indexed by * or @, then offset and length
 665            refer to the array index and number of elements respectively. A
 666            negative offset is taken relative to one greater than the highest
 667            subscript for indexed arrays. The order for associative arrays is
 668            unspecified.
 669 
 670 
 671        ${parameter#pattern}
 672        ${parameter##pattern}
 673 
 674            If the shell pattern matches the beginning of the value of
 675            parameter, then the value of this expansion is the value of the
 676            parameter with the matched portion deleted. Otherwise the value of
 677            this parameter is substituted. In the first form the smallest
 678            matching pattern is deleted and in the second form the largest
 679            matching pattern is deleted. When parameter is @, *, or an array
 680            variable with subscript @ or *, the substring operation is applied
 681            to each element in turn.
 682 
 683 
 684        ${parameter%pattern}
 685        ${parameter%%pattern}
 686 
 687            If the shell pattern matches the end of the value of parameter,
 688            then the value of this expansion is the value of the parameter with
 689            the matched part deleted. Otherwise substitute the value of
 690            parameter. In the first form the smallest matching pattern is
 691            deleted, and in the second form the largest matching pattern is
 692            deleted. When parameter is @, *, or an array variable with
 693            subscript @ or *, the substring operation is applied to each
 694            element in turn.
 695 
 696 
 697        ${parameter/pattern/string}
 698        ${parameter//pattern/string}
 699        ${parameter/#pattern/string}
 700        ${parameter/%pattern/string}
 701 
 702            Expands parameter and replaces the longest match of pattern with
 703            the specified string. Each occurrence of \n in string is replaced
 704            by the portion of parameter that matches the nth sub-pattern.
 705 
 706            When string is null, the pattern is deleted and the / in front of
 707            string can be omitted. When parameter is @, *, or an array variable
 708            with subscript @ or *, the substitution operation is applied to
 709            each element in turn. In this case, the string portion of word is
 710            re-evaluated for each element.
 711 
 712            In the first form, only the first occurrence of pattern is
 713            replaced.
 714 
 715            In the second form, each match for pattern is replaced by the
 716            specified string.
 717 
 718            The third form restricts the pattern match to the beginning of the
 719            string.
 720 
 721            The fourth form restricts the pattern match to the end of the
 722            string.
 723 
 724 
 725 
 726        The following parameters are automatically set by the shell:
 727 
 728        #
 729                           The number of positional parameters in decimal.
 730 
 731 
 732        -
 733                           Options supplied to the shell on invocation or by
 734                           the set command.
 735 
 736 
 737        ?
 738                           The decimal value returned by the last executed
 739                           command.
 740 
 741 
 742        $
 743                           The process number of this shell.
 744 
 745 
 746        _
 747                           Initially, the value of _ is the absolute pathname
 748                           of the shell or script being executed as passed in
 749                           the environment. It is subsequently assigned the
 750                           last argument of the previous command.
 751 
 752                           This parameter is not set for commands which are
 753                           asynchronous. This parameter is also used to hold
 754                           the name of the matching MAIL file when checking for
 755                           mail.
 756 
 757 
 758        !
 759                           The process id or the pool name and job number of
 760                           the last background command invoked or the most
 761                           recent job put in the background with the bg built-
 762                           in command. Background jobs started in a named pool
 763                           with be in the form pool.number where pool is the
 764                           pool name and number is the job number within that
 765                           pool.
 766 
 767 
 768        .sh.command
 769                           When processing a DEBUG trap, this variable contains
 770                           the current command line that is about to run.
 771 
 772 
 773        .sh.edchar
 774                           This variable contains the value of the keyboard
 775                           character (or sequence of characters if the first
 776                           character is an ESC, ASCII 033) that has been
 777                           entered when processing a KEYBD trap. If the value
 778                           is changed as part of the trap action, then the new
 779                           value replaces the key (or key sequence) that caused
 780                           the trap. See the Key Bindings section of this
 781                           manual page.
 782 
 783 
 784        .sh.edcol
 785                           The character position of the cursor at the time of
 786                           the most recent KEYBD trap.
 787 
 788 
 789        .sh.edmode
 790                           The value is set to ESC when processing a KEYBD trap
 791                           while in vi insert mode. Otherwise, .sh.edmode is
 792                           null when processing a KEYBD trap. See the vi
 793                           Editing Mode section of this manual page.
 794 
 795 
 796        .sh.edtext
 797                           The characters in the input buffer at the time of
 798                           the most recent KEYBD trap. The value is null when
 799                           not processing a KEYBD trap.
 800 
 801 
 802        .sh.file
 803                           The pathname of the file than contains the current
 804                           command.
 805 
 806 
 807        .sh.fun
 808                           The name of the current function that is being
 809                           executed.
 810 
 811 
 812        .sh.match
 813                           An indexed array which stores the most recent match
 814                           and sub-pattern matches after conditional pattern
 815                           matches that match and after variables expansions
 816                           using the operators #, %, or /. The 0th element
 817                           stores the complete match and the ith element stores
 818                           the ith sub-match.  The .sh.match variable is unset
 819                           when the variable that has expanded is assigned a
 820                           new value.
 821 
 822 
 823        .sh.math
 824                           Used for defining arithmetic functions (see
 825                           Arithmetic evaluation) and stores the list of user-
 826                           defined arithmetic functions.
 827 
 828 
 829        .sh.name
 830                           Set to the name of the variable at the time that a
 831                           discipline function is invoked.
 832 
 833 
 834        .sh.subscript
 835                           Set to the name subscript of the variable at the
 836                           time that a discipline function is invoked.
 837 
 838 
 839        .sh.subshell
 840                           The current depth for sub-shells and command
 841                           substitution.
 842 
 843 
 844        .sh.value
 845                           Set to the value of the variable at the time that
 846                           the set or append discipline function is invoked.
 847                           When a user-defined arithmetic function is invoked,
 848                           the value of .sh.value is saved and .sh.value is set
 849                           to long double precision floating point. .sh.value
 850                           is restored when the function returns.
 851 
 852 
 853        .sh.version
 854                           Set to a value that identifies the version of this
 855                           shell.
 856 
 857 
 858        LINENO
 859                           The current line number within the script or
 860                           function being executed.
 861 
 862 
 863        OLDPWD
 864                           The previous working directory set by the cd
 865                           command.
 866 
 867 
 868        OPTARG
 869                           The value of the last option argument processed by
 870                           the getopts built-in command.
 871 
 872 
 873        OPTIND
 874                           The index of the last option argument processed by
 875                           the getopts built-in command.
 876 
 877 
 878        PPID
 879                           The process number of the parent of the shell.
 880 
 881 
 882        PWD
 883                           The present working directory set by the cd command.
 884 
 885 
 886        RANDOM
 887                           Each time this variable is referenced, a random
 888                           integer, uniformly distributed between 0 and 32767,
 889                           is generated. The sequence of random numbers can be
 890                           initialized by assigning a numeric value to RANDOM.
 891 
 892 
 893        REPLY
 894                           This variable is set by the select statement and by
 895                           the read built-in command when no arguments are
 896                           supplied.
 897 
 898 
 899        SECONDS
 900                           Each time this variable is referenced, the number of
 901                           seconds since shell invocation is returned. If this
 902                           variable is assigned a value, then the value
 903                           returned upon reference is the value that was
 904                           assigned plus the number of seconds since the
 905                           assignment.
 906 
 907 
 908        SHLVL
 909                           An integer variable the is incremented each time the
 910                           shell is invoked and is exported.  If SHLVL is not
 911                           in the environment when the shell is invoked, it is
 912                           set to 1.
 913 
 914 
 915 
 916        The following variables are used by the shell:
 917 
 918        CDPATH
 919                      Defines the search path for the cd command.
 920 
 921 
 922        COLUMNS
 923                      Defines the width of the edit window for the shell edit
 924                      modes and for printing select lists.
 925 
 926 
 927        EDITOR
 928                      If the VISUAL variable is not set, the value of this
 929                      variable is checked for the patterns as described with
 930                      VISUAL and the corresponding editing option is turned on.
 931 
 932                      See the set command in the Special Command section of
 933                      this manual page.
 934 
 935 
 936        ENV
 937                      Performs parameter expansion, command substitution, and
 938                      arithmetic substitution on the value to generate the
 939                      pathname of the script that is executed when the shell is
 940                      invoked. This file is typically used for alias and
 941                      function definitions. The default value is $HOME/.kshrc.
 942 
 943                      See the Invocation section of this manual page.
 944 
 945                      ENV is not set by the shell.
 946 
 947 
 948        FCEDIT
 949                      Obsolete name for the default editor name for the hist
 950                      command.  FCEDIT is not used when HISTEDIT is set.
 951 
 952                      The shell specifies a default value to FCEDIT.
 953 
 954 
 955        FIGNORE
 956                      A pattern that defines the set of file names that is
 957                      ignored when performing file name matching.
 958 
 959 
 960        FPATH
 961                      The search path for function definitions. The directories
 962                      in this path are searched for a file with the same name
 963                      as the function or command when a function with the -u
 964                      attribute is referenced and when a command is not found.
 965                      If an executable file with the name of that command is
 966                      found, then it is read and executed in the current
 967                      environment. Unlike PATH, the current directory must be
 968                      represented explicitly by dot (.) rather than by adjacent
 969                      colon (:) characters or a beginning or ending colon (:).
 970 
 971 
 972        HISTCMD
 973                      The number of the current command in the history file.
 974 
 975 
 976        HISTEDIT
 977                      The name for the default editor name for the hist
 978                      command.
 979 
 980 
 981        HISTFILE
 982                      If this variable is set when the shell is invoked, the
 983                      value is the pathname of the file that is used to store
 984                      the command history. See the Command Re-entry section of
 985                      this manual page.
 986 
 987 
 988        HISTSIZE
 989                      If this variable is set when the shell is invoked, then
 990                      the number of previously entered commands that are
 991                      accessible by this shell is greater than or equal to this
 992                      number. The default is 512.
 993 
 994 
 995        HOME
 996                      The default argument (home directory) for the cd command.
 997 
 998                      HOME is not set by the shell. HOME is set by login(1).
 999 
1000 
1001        IFS
1002                      Internal field separators, normally SPACE, TAB, and
1003                      NEWLINE that are used to separate the results of command
1004                      substitution or parameter expansion and to separate
1005                      fields with the built-in command read. The first
1006                      character of the IFS variable is used to separate
1007                      arguments for the "$*" substitution. See the Quoting
1008                      section of this manual page.
1009 
1010                      Each single occurrence of an IFS character in the string
1011                      to be split, that is not in the issspace character class,
1012                      and any adjacent characters in IFS that are in the
1013                      issspace character class, delimit a field.  One or more
1014                      characters in IFS that belong to the issspace character
1015                      class, delimit a field. In addition, if the same issspace
1016                      character appears consecutively inside IFS, this
1017                      character is treated as if it were not in the issspace
1018                      class, so that if IFS consists of two tab characters,
1019                      then two adjacent tab characters delimit a null field.
1020 
1021                      The shell specifies a default value to IFS.
1022 
1023 
1024        JOBMAX
1025                      This variable defines the maximum number running
1026                      background jobs that can run at a time.  When this limit
1027                      is reached, the shell will wait for a job to complete
1028                      before staring a new job.
1029 
1030 
1031        LANG
1032                      This variable determines the locale category for any
1033                      category not specifically selected with a variable
1034                      starting with LC_ or LANG.
1035 
1036 
1037        LC_ALL
1038                      This variable overrides the value of the LANG variable
1039                      and any other LC_ variable.
1040 
1041 
1042        LC_COLLATE
1043                      This variable determines the locale category for
1044                      character collation information.
1045 
1046 
1047        LC_CTYPE
1048                      This variable determines the locale category for
1049                      character handling functions.  It determines the
1050                      character classes for pattern matching. See the File Name
1051                      Generation section of this manual page.
1052 
1053 
1054        LC_NUMERIC
1055                      This variable determines the locale category for the
1056                      decimal point character.
1057 
1058 
1059        LINES
1060                      If this variable is set, the value is used to determine
1061                      the column length for printing select lists. Select lists
1062                      prints vertically until about two-thirds of LINES lines
1063                      are filled.
1064 
1065 
1066        MAIL
1067                      If this variable is set to the name of a mail file and
1068                      the MAILPATH variable is not set, then the shell informs
1069                      the user of arrival of mail in the specified file.
1070 
1071                      MAIL is not set by the shell. On some systems, MAIL is
1072                      set by login(1).
1073 
1074 
1075        MAILCHECK
1076                      Specifies how often in seconds the shell checks for
1077                      changes in the modification time of any of the files
1078                      specified by the MAILPATH or MAIL variables. The default
1079                      value is 600 seconds. When the time has elapsed the shell
1080                      checks before issuing the next prompt.
1081 
1082                      The shell specifies a default value to MAILCHECK.
1083 
1084 
1085        MAILPATH
1086                      A colon ( : ) separated list of file names. If this
1087                      variable is set, then the shell informs the user of any
1088                      modifications to the specified files that have occurred
1089                      within the last MAILCHECK seconds. Each file name can be
1090                      followed by a ? and a message that is printed. The
1091                      message undergoes parameter expansion, command
1092                      substitution, and arithmetic substitution with the
1093                      variable $_ defined as the name of the file that has
1094                      changed. The default message is you have mail in $_.
1095 
1096 
1097        PATH
1098                      The search path for commands. Except in .profile, users
1099                      cannot change PATH if executing under rksh93. See the
1100                      Execution section of this manual page.
1101 
1102                      The shell specifies a default value to PATH.
1103 
1104 
1105        PS1
1106                      The value of this variable is expanded for parameter
1107                      expansion, command substitution, and arithmetic
1108                      substitution to define the primary prompt string which by
1109                      default is $. The character ! in the primary prompt
1110                      string is replaced by the command number. Two successive
1111                      occurrences of ! produces a single ! when the prompt
1112                      string is printed. See the Command Re-entry section of
1113                      this manual page.
1114 
1115                      The shell specifies a default value to PS1.
1116 
1117 
1118        PS2
1119                      Secondary prompt string, by default, >.
1120 
1121                      The shell specifies a default value to PS2.
1122 
1123 
1124        PS3
1125                      Selection prompt string used within a select loop, by
1126                      default #?.
1127 
1128                      The shell specifies a default value to PS3.
1129 
1130 
1131        PS4
1132                      The value of this variable is expanded for parameter
1133                      evaluation, command substitution, and arithmetic
1134                      substitution and precedes each line of an execution
1135                      trace. By default, PS4 is +. When PS4 is unset, the
1136                      execution trace prompt is also + .
1137 
1138                      The shell specifies a default value to PS4.
1139 
1140 
1141        SHELL
1142                      The pathname of the shell is kept in the environment. At
1143                      invocation, if the basename of this variable is rsh,
1144                      rksh, rksh93, or krsh, the shell becomes restricted.
1145 
1146                      SHELL is not set by the shell. On some systems, SHELL is
1147                      set by login(1).
1148 
1149 
1150        TIMEFORMAT
1151                      The value of this parameter is used as a format string
1152                      specifying how the timing information for pipelines
1153                      prefixed with the time reserved word should be displayed.
1154                      The % character introduces a format sequence that is
1155                      expanded to a time value or other information.
1156 
1157                      The format sequences and their meanings are as follows.
1158 
1159                      %%
1160 
1161                          A literal %.
1162 
1163 
1164                      %[p][l]R
1165 
1166                          The elapsed time in seconds.
1167 
1168 
1169                      %[p][l]U
1170 
1171                          The number of CPU seconds spent in user mode.
1172 
1173 
1174                      %[p][l]S
1175 
1176                          The number of CPU seconds spent in system mode.
1177 
1178 
1179                      %P
1180 
1181                          The CPU percentage, computed as (U + S) / R.
1182 
1183                      The braces denote optional portions. The optional p is a
1184                      digit specifying the precision, the number of fractional
1185                      digits after a decimal point. A value of 0 causes no
1186                      decimal point or fraction to be output. At most three
1187                      places after the decimal point can be displayed. Values
1188                      of p greater than 3 are treated as 3. If p is not
1189                      specified, the value 3 is used.
1190 
1191                      The optional l specifies a longer format, including hours
1192                      if greater than zero, minutes, and seconds of the form
1193                      HHhMMmSS.FFs. The value of p determines whether or not
1194                      the fraction is included.
1195 
1196                      All other characters are output without change and a
1197                      trailing NEWLINE is added.  If unset, the default value,
1198                      $'\nreal\t%2lR\nuser\t%2lU\nsys%2lS', is used. If the
1199                      value is null, no timing information is displayed.
1200 
1201 
1202        TMOUT
1203                      If set to a value greater than zero, TMOUT is the default
1204                      time-out value for the read built-in command. The select
1205                      compound command terminates after TMOUT seconds when
1206                      input is from a terminal. Otherwise, the shell terminates
1207                      if a line is not entered within the prescribed number of
1208                      seconds while reading from a terminal. The shell can be
1209                      compiled with a maximum bound for this value which cannot
1210                      be exceeded.
1211 
1212                      The shell specifies a default value to TMOUT.
1213 
1214 
1215        VISUAL
1216                      If the value of this variable matches the pattern
1217                      *[Vv][Ii]*, then the vi option is turned on. See Special
1218                      Commands. If the value matches the pattern *gmacs* , the
1219                      gmacs option is turned on. If the value matches the
1220                      pattern *macs*, then the emacs option is turned on. The
1221                      value of VISUAL overrides the value of EDITOR.
1222 
1223 
1224    Field Splitting
1225        After parameter expansion and command substitution, the results of
1226        substitutions are scanned for the field separator characters (those
1227        found in IFS) and split into distinct fields where such characters are
1228        found.  Explicit null fields ("" or '') are retained. Implicit null
1229        fields, those resulting from parameters that have no values or command
1230        substitutions with no output, are removed.
1231 
1232 
1233        If the braceexpand (-B) option is set, each of the fields resulting
1234        from IFS are checked to see if they contain one or more of the brace
1235        patterns. Valid brace patterns: {*,*}, {l1..l2} , {n1..n2},
1236        {n1..n2%fmt} {n1..n2 ..n3}, or {n1..n2 ..n3%fmt} , where * represents
1237        any character, l1,l2 are letters and n1,n2,n3 are signed numbers and
1238        fmt is a format specified as used by printf. In each case, fields are
1239        created by prepending the characters before the { and appending the
1240        characters after the } to each of the strings generated by the
1241        characters between the { and }. The resulting fields are checked to see
1242        if they have any brace patterns.
1243 
1244 
1245        In the first form, a field is created for each string between { and ,,
1246        between , and ,, and between , and }. The string represented by * can
1247        contain embedded matching { and } without quoting.  Otherwise, each {
1248        and } with * must be quoted.
1249 
1250 
1251        In the second form, l1 and l2 must both be either upper case or both be
1252        lower case characters in the C locale. In this case a field is created
1253        for each character from l1 through l2.
1254 
1255 
1256        In the remaining forms, a field is created for each number starting at
1257        n1. This continues until it reaches n2 and increments n1 by n3. The
1258        cases where n3 is not specified behave as if n3 were 1 if n1<=n2, and
1259        -1 otherwise. In forms which specify %fmt, any format flags, widths and
1260        precisions can be specified and fmt can end in any of the specifiers
1261        cdiouxX. For example, {a,z}{1..5..3%02d}{b..c}x expands to the 8
1262        fields, a01bx, a01cx, a04bx, a04cx, z01bx, z01cx, z04bx, and z04cx.
1263 
1264    File Name Generation
1265        Following splitting, each field is scanned for the characters *, ?, (,
1266        and [, unless the -f option has been set. If one of these characters
1267        appears, then the word is regarded as a pattern.
1268 
1269 
1270        Each file name component that contains any pattern character is
1271        replaced with a lexicographically sorted set of names that matches the
1272        pattern from that directory. If no file name is found that matches the
1273        pattern, then that component of the file name is left unchanged unless
1274        the pattern is prefixed with ~(N) in which case it is removed. If
1275        FIGNORE is set, then each file name component that matches the pattern
1276        defined by the value of FIGNORE is ignored when generating the matching
1277        file names. The names . and .. are also ignored. If FIGNORE is not set,
1278        the character . at the start of each file name component is ignored
1279        unless the first character of the pattern corresponding to this
1280        component is the character . itself. For other uses of pattern matching
1281        the / and . are not specially treated.
1282 
1283        *
1284                   Match any string, including the null string. When used for
1285                   file name expansion, if the globstar option is on, two
1286                   adjacent *s by themselves match all files and zero or more
1287                   directories and subdirectories. If the two adjacent *s are
1288                   followed by a /, only directories and subdirectories match.
1289 
1290 
1291        ?
1292                   Matches any single character.
1293 
1294 
1295        [...]
1296                   Match any one of the enclosed characters. A pair of
1297                   characters separated by - matches any character lexically
1298                   between the pair, inclusive. If the first character
1299                   following the opening [ is a ! or ^, any character not
1300                   enclosed is matched. A - can be included in the character
1301                   set by putting it as the first or last character. Within [
1302                   and ], character classes can be specified with the syntax
1303                   [:class:] where class is one of the following classes
1304                   defined in the ANSI-C standard:
1305 
1306                     alnum alpha blank cntrl digit graph
1307                     lower print punct space upper
1308                     word xdigit
1309 
1310 
1311                   word is equivalent to alnum plus the character _. Within [
1312                   and ], an equivalence class can be specified with the syntax
1313                   [=c=] which matches all characters with the same primary
1314                   collation weight (as defined by the current locale) as the
1315                   character c.  Within [ and ], [.symbol.] matches the
1316                   collating symbol symbol.
1317 
1318 
1319 
1320        A pattern-list is a list of one or more patterns separated from each
1321        other with an & or |. An     & signifies that all patterns must be matched
1322        whereas | requires that only one pattern be matched. Composite patterns
1323        can be formed with one or more of the following sub-patterns:
1324 
1325        ?(pattern-list)
1326                              Optionally matches any one of the specified
1327                              patterns.
1328 
1329 
1330        *(pattern-list)
1331                              Matches zero or more occurrences of the specified
1332                              patterns.
1333 
1334 
1335        +(pattern-list)
1336                              Matches one or more occurrences of the specified
1337                              patterns.
1338 
1339 
1340        {n(pattern-list)
1341                              Matches n occurrences of the specified patterns.
1342 
1343 
1344        {m,n(pattern-list)
1345                              Matches from m to n occurrences of the specified
1346                              patterns. If m is omitted, 0 is used. If n is
1347                              omitted at least m occurrences are matched.
1348 
1349 
1350        @(pattern-list)
1351                              Matches exactly one of the specified patterns.
1352 
1353 
1354        !(pattern-list)
1355                              Matches anything except one of the specified
1356                              patterns.
1357 
1358 
1359 
1360        By default, each pattern, or sub-pattern matches the longest string
1361        possible consistent with generating the longest overall match. If more
1362        than one match is possible, the one starting closest to the beginning
1363        of the string is chosen.  However, for each of the compound patterns a
1364        - can be inserted in front of the ( to cause the shortest match to the
1365        specified pattern-list to be used.
1366 
1367 
1368        When pattern-list is contained within parentheses, the backslash
1369        character \ is treated specially even when inside a character class.
1370        All ANSI-C character escapes are recognized and match the specified
1371        character. In addition the following escape sequences are recognized:
1372 
1373        \d
1374               Matches any character in the digit class.
1375 
1376 
1377        \D
1378               Matches any character not in the digit class.
1379 
1380 
1381        \s
1382               Matches any character in the space class.
1383 
1384 
1385        \S
1386               Matches any character not in the space class.
1387 
1388 
1389        \w
1390               Matches any character in the word class.
1391 
1392 
1393        \W
1394               Matches any character not in the word class.
1395 
1396 
1397 
1398        A pattern of the form %(pattern-pairs) is a sub-pattern that can be
1399        used to match nested character expressions. Each pattern-pair is a two
1400        character sequence which cannot contain & or |. The first pattern-pair
1401        specifies the starting and ending characters for the match.  Each
1402        subsequent pattern-pair represents the beginning and ending characters
1403        of a nested group that is skipped over when counting starting and
1404        ending character matches. The behavior is unspecified when the first
1405        character of a pattern-pair is alphanumeric except for the following:
1406 
1407        D
1408             Causes the ending character to terminate the search for this
1409             pattern without finding a match.
1410 
1411 
1412        E
1413             Causes the ending character to be interpreted as an escape
1414             character.
1415 
1416 
1417        L
1418             Causes the ending character to be interpreted as a quote character
1419             causing all characters to be ignored when looking for a match.
1420 
1421 
1422        Q
1423             Causes the ending character to be interpreted as a quote character
1424             causing all characters other than any escape character to be
1425             ignored when looking for a match.
1426 
1427 
1428 
1429        %({}Q"E\), matches characters starting at { until the matching } is
1430        found not counting any { or } that is inside a double quoted string or
1431        preceded by the escape character \. Without the {} this pattern matches
1432        any C language string.
1433 
1434 
1435        Each sub-pattern in a composite pattern is numbered, starting at 1, by
1436        the location of the ( within the pattern. The sequence \n, where n is a
1437        single digit and \n comes after the nth.  sub-pattern, matches the same
1438        string as the sub-pattern itself.
1439 
1440 
1441        A pattern can contain sub-patterns of the form ~(options:pattern-list),
1442        where either options or :pattern-list can be omitted. Unlike the other
1443        compound patterns, these sub-patterns are not counted in the numbered
1444        sub-patterns. :pattern-list must be omitted for options F, G, N and V
1445        below.  If options is present, it can consist of one or more of the
1446        following:
1447 
1448        +
1449             Enable the following options. This is the default.
1450 
1451 
1452        -
1453             Disable the following options.
1454 
1455 
1456        E
1457             The remainder of the pattern uses extended regular expression
1458             syntax like the egrep(1) command.
1459 
1460 
1461        F
1462             The remainder of the pattern uses fgrep(1) expression syntax.
1463 
1464 
1465        g
1466             File the longest match (greedy).
1467 
1468             This is the default.
1469 
1470 
1471        G
1472             The remainder of the pattern uses basic regular expression syntax
1473             like the grep(1) command.
1474 
1475 
1476        i
1477             Treat the match as case insensitive.
1478 
1479 
1480        K
1481             The remainder of the pattern uses shell pattern syntax.
1482 
1483             This is the default.
1484 
1485 
1486        l
1487             Left anchor the pattern.
1488 
1489             This is the default for K style patterns.
1490 
1491 
1492        N
1493             This is ignored. However, when it is the first letter and is used
1494             with file name generation, and no matches occur, the file pattern
1495             expands to the empty string.
1496 
1497 
1498        r
1499             Right anchor the pattern.
1500 
1501             This is the default for K style patterns.
1502 
1503 
1504        X
1505             The remainder of the pattern uses augmented regular expression
1506             syntax.
1507 
1508 
1509        P
1510             The remainder of the pattern uses perl(1) regular expression
1511             syntax. Not all perl regular expression syntax is currently
1512             implemented.
1513 
1514 
1515        V
1516             The remainder of the pattern uses System V regular expression
1517             syntax.
1518 
1519 
1520 
1521        If both options and :pattern-list are specified, then the options apply
1522        only to pattern-list. Otherwise, these options remain in effect until
1523        they are disabled by a subsequent ~(...) or at the end of the sub-
1524        pattern containing ~(...).
1525 
1526    Quoting
1527        Each of the metacharacters listed in the Definitions section of this
1528        manual page has a special meaning to the shell and causes termination
1529        of a word unless quoted. A character can be quoted, that is, made to
1530        stand for itself, by preceding it with a backslash (\). The pair
1531        \NEWLINE is removed.  All characters enclosed between a pair of single
1532        quote marks ('') that is not preceded by a $ are quoted. A single quote
1533        cannot appear within the single quotes. A single quoted string preceded
1534        by an unquoted $ is processed as an ANSI-C string except for the
1535        following:
1536 
1537        \0
1538                           Causes the remainder of the string to be ignored.
1539 
1540 
1541        \cx
1542                           Expands to the character CTRL-x.
1543 
1544 
1545        \C[.name.]
1546                           Expands to the collating element name.
1547 
1548 
1549        \e
1550                           Equivalent to the escape character (ASCII 033),
1551 
1552 
1553        \E
1554                           Equivalent to the escape character (ASCII 033),
1555 
1556 
1557 
1558        Inside double quote marks (""), parameter and command substitution
1559        occur and \ quotes the characters \, `, ", and $. A $ in front of a
1560        double quoted string is ignored in the C or POSIX locale, and might
1561        cause the string to be replaced by a locale specific string otherwise.
1562        The meaning of $* and $@ is identical when not quoted or when used as a
1563        variable assignment value or as a file name.  However, when used as a
1564        command argument, "$*" is equivalent to "$1d$2d...", where d is the
1565        first character of the IFS variable, whereas "$@" is equivalent to "$1"
1566        "$2" .... Inside grave quote marks (``), \ quotes the characters \, `,
1567        and $. If the grave quotes occur within double quotes, then \ also
1568        quotes the character ".
1569 
1570 
1571        The special meaning of reserved words or aliases can be removed by
1572        quoting any character of the reserved word. The recognition of function
1573        names or built-in command names cannot be altered by quoting them.
1574 
1575    Arithmetic Evaluation
1576        The shell performs arithmetic evaluation for arithmetic substitution,
1577        to evaluate an arithmetic command, to evaluate an indexed array
1578        subscript, and to evaluate arguments to the built-in commands shift and
1579        let.  Arithmetic evaluation is also performed on argument operands of
1580        the built-in command printf that correspond to numeric format
1581        specifiers in the format operand. See printf(1). Evaluations are
1582        performed using double precision floating point arithmetic or long
1583        double precision floating point for systems that provide this data
1584        type. Floating point constants follow the ANSI-C programming language
1585        floating point conventions. The floating point constants Nan and Inf
1586        can be used to represent "not a number" and infinity respectively.
1587        Integer constants follow the ANSI-C programming language integer
1588        constant conventions although only single byte character constants are
1589        recognized and character casts are not recognized. Constants can be of
1590        the form [base#]n where base is a decimal number between two and sixty-
1591        four representing the arithmetic base and n is a number in that base.
1592        The digits greater than 9 are represented by the lower case letters,
1593        the upper case letters, @, and _ respectively. For bases less than or
1594        equal to 36, upper and lower case characters can be used
1595        interchangeably.
1596 
1597 
1598        An arithmetic expression uses the same syntax, precedence, and
1599        associativity of expression as the C language. All the C language
1600        operators that apply to floating point quantities can be used. In
1601        addition, the operator ** can be used for exponentiation. It has higher
1602        precedence than multiplication and is left associative. When the value
1603        of an arithmetic variable or subexpression can be represented as a long
1604        integer, all C language integer arithmetic operations can be performed.
1605        Variables can be referenced by name within an arithmetic expression
1606        without using the parameter expansion syntax. When a variable is
1607        referenced, its value is evaluated as an arithmetic expression.
1608 
1609 
1610        Any of the following math library functions that are in the C math
1611        library can be used within an arithmetic expression:
1612 
1613          rint round sin sinh sqrt tan tanh tgamma trunc abs acos
1614          acosh asin asinh atan atan2 atanh cbrt ceil copysign cos
1615          cosh erf erfc exp exp2 expm1 fabs fpclassify fdim finite
1616          floor fma fmax fmin fmod hypot ilogb int isfinite sinf isnan
1617          isnormal issubnormal issubor- dered iszero j0 j1 jn lgamma
1618          log log10 log2 logb nearbyint nextafter nexttoward pow
1619          remainder rint round scanb signbit sin sinh sqrt tan tanh
1620          tgamma trunc y0 y1 yn
1621 
1622 
1623 
1624 
1625        In addition, arithmetic functions can be defined as shell functions
1626        with a variant of the function name syntax:
1627 
1628        function .sh.math.name ident ... { list ;}
1629             where name is the function name used in the arithmetic expression
1630             and each identified ident is a name reference to the long double
1631             precision floating point argument. The value of .sh.value when the
1632             function returns is the value of this function. User defined
1633             functions can take up to 3 arguments and override C math library
1634             functions.
1635 
1636 
1637 
1638        An internal representation of a variable as a double precision floating
1639        point can be specified with the -E [n], -F [n], or -X [n] options of
1640        the typeset special built-in command. The -E option causes the
1641        expansion of the value to be represented using scientific notation when
1642        it is expanded. The optional option argument n defines the number of
1643        significant figures. The -F option causes the expansion to be
1644        represented as a floating decimal number when it is expanded.  The
1645        optional option argument n defines the number of places after the
1646        decimal point in this case. The -X option causes the expansion to be
1647        represented using the %a format defined by ISO C-99. The optional
1648        option argument n defines the number of places after the decimal (or
1649        radix) point in this case.
1650 
1651 
1652 
1653        An internal integer representation of a variable can be specified with
1654        the -i [n] option of the typeset special built-in command. The optional
1655        option argument n specifies an arithmetic base to be used when
1656        expanding the variable. If you do not specify an arithmetic base, base
1657        10 is used.
1658 
1659 
1660        Arithmetic evaluation is performed on the value of each assignment to a
1661        variable with the -E, -F, -X or -i option. Assigning a floating point
1662        number to a variable whose type is an integer causes the fractional
1663        part to be truncated.
1664 
1665    Prompting
1666        When used interactively, the shell prompts with the value of PS1 after
1667        expanding it for parameter expansion, command substitution, and
1668        arithmetic substitution, before reading a command. In addition, each
1669        single ! in the prompt is replaced by the command number. A !! is
1670        required to place ! in the prompt. If at any time a NEWLINE is typed
1671        and further input is needed to complete a command, then the secondary
1672        prompt, that is, the value of PS2, is issued.
1673 
1674    Conditional Expressions
1675        A conditional expression is used with the [[ compound command to test
1676        attributes of files and to compare strings. Field splitting and file
1677        name generation are not performed on the words between [[ and ]].
1678 
1679 
1680        Each expression can be constructed from one or more of the following
1681        unary or binary expressions:
1682 
1683        -a file
1684                             True, if file exists.
1685 
1686                             This option is the same as -e. This option is
1687                             obsolete.
1688 
1689 
1690        -b file
1691                             True, if file exists and is a block special file.
1692 
1693 
1694        -c file
1695                             True, if file exists and is a character special
1696                             file.
1697 
1698 
1699        -d file
1700                             True, if file exists and is a directory.
1701 
1702 
1703        -e file
1704                             True, if file exists.
1705 
1706 
1707        -f file
1708                             True, if file exists and is an ordinary file.
1709 
1710 
1711        -g file
1712                             True, if file exists and it has its setgid bit
1713                             set.
1714 
1715 
1716        -G file
1717                             True, if file exists and its group matches the
1718                             effective group id of this process.
1719 
1720 
1721        -h file
1722                             True, if file exists and is a symbolic link.
1723 
1724 
1725        -k file
1726                             True, if file exists and it has its sticky bit
1727                             set.
1728 
1729 
1730        -L file
1731                             True, if file exists and is a symbolic link.
1732 
1733 
1734        -n string
1735                             True, if length of string is non-zero.
1736 
1737 
1738        -N file
1739                             True, if file exists and the modification time is
1740                             greater than the last access time.
1741 
1742 
1743        -o option
1744                             True, if option named option is on.
1745 
1746 
1747        -o ?option
1748                             True, if option named option is a valid option
1749                             name.
1750 
1751 
1752        -O file
1753                             True, if file exists and is owned by the effective
1754                             user id of this process.
1755 
1756 
1757        -p file
1758                             True, if file exists and is a FIFO special file or
1759                             a pipe.
1760 
1761 
1762        -r file
1763                             True, if file exists and is readable by current
1764                             process.
1765 
1766 
1767        -R name
1768                             True if variable name is a name reference.
1769 
1770 
1771        -s file
1772                             True, if file exists and has size greater than
1773                             zero.
1774 
1775 
1776        -S file
1777                             True, if file exists and is a socket.
1778 
1779 
1780        -t fildes
1781                             True, if file descriptor number fildes is open and
1782                             associated with a terminal device.
1783 
1784 
1785        -u file
1786                             True, if file exists and it has its setuid bit
1787                             set.
1788 
1789 
1790        -v name
1791                             True, if variable name is a valid variable name
1792                             and is set.
1793 
1794 
1795        -w file
1796                             True, if file exists and is writable by current
1797                             process.
1798 
1799 
1800        -x file
1801                             True, if file exists and is executable by current
1802                             process. If file exists and is a directory, then
1803                             true if the current process has permission to
1804                             search in the directory.
1805 
1806 
1807        -z string
1808                             True, if length of string is zero.
1809 
1810 
1811        file1 -ef file2
1812                             True, if file1 and file2 exist and refer to the
1813                             same file.
1814 
1815 
1816        file1 -nt file2
1817                             True, if file1 exists and file2 does not, or file1
1818                             is newer than file2.
1819 
1820 
1821        file1 -ot file2
1822                             True, if file2 exists and file1 does not, or file1
1823                             is older than file2.
1824 
1825 
1826        string
1827                             True, if string is not null.
1828 
1829 
1830        string == pattern
1831                             True, if string matches pattern. Any part of
1832                             pattern can be quoted to cause it to be matched as
1833                             a string. With a successful match to pattern, the
1834                             .sh.match array variable contains the match and
1835                             sub-pattern matches.
1836 
1837 
1838        string = pattern
1839                             Same as ==, but is obsolete.
1840 
1841 
1842        string != pattern
1843                             True, if string does not match pattern. When the
1844                             string matches the pattern the .sh.match array
1845                             variable contains the match and sub-pattern
1846                             matches.
1847 
1848 
1849        string =~ ere
1850                             True if string matches the pattern ~(E)ere where
1851                             ere is an extended regular expression.
1852 
1853 
1854        string1 < string2
1855                             True, if string1 comes before string2 based on
1856                             ASCII value of their characters.
1857 
1858 
1859        string1 > string2
1860                             True, if string1 comes after string2 based on
1861                             ASCII value of their characters.
1862 
1863 
1864        In each of the above expressions, if file is of the form /dev/fd/n,
1865        where n is an integer, the test is applied to the open file whose
1866        descriptor number is n.
1867 
1868 
1869        The following obsolete arithmetic comparisons are also supported:
1870 
1871        exp1 -eq exp2
1872                         True, if exp1 is equal to exp2.
1873 
1874 
1875        exp1 -ge exp2
1876                         True, if exp1 is greater than or equal to exp2.
1877 
1878 
1879        exp1 -gt exp2
1880                         True, if exp1 is greater than exp2.
1881 
1882 
1883        exp1 -le exp2
1884                         True, if exp1 is less than or equal to exp2.
1885 
1886 
1887        exp1 -lt exp2
1888                         True, if exp1 is less than exp2.
1889 
1890 
1891        exp1 -ne exp2
1892                         True, if exp1 is not equal to exp2.
1893 
1894 
1895 
1896        A compound expression can be constructed from these primitives by using
1897        any of the following, listed in decreasing order of precedence:
1898 
1899        (expression)
1900                                      True, if expression is true. Used to
1901                                      group expressions.
1902 
1903 
1904        ! expression
1905                                      True, if expression is false.
1906 
1907 
1908        expression1 && expression2
1909                                      True, if expression1 and expression2 are
1910                                      both true.
1911 
1912 
1913        expression1 || expression2
1914                                      True, if either expression1 or
1915                                      expression2 is true.
1916 
1917 
1918    Input and Output
1919        Before a command is executed, its input and output can be redirected
1920        using a special notation interpreted by the shell. The following can
1921        appear anywhere in a simple command or can precede or follow a command
1922        and are not passed on to the invoked command. Command substitution,
1923        parameter expansion, and arithmetic substitution occur before word or
1924        digit is used except as noted in this section. File name generation
1925        occurs only if the shell is interactive and the pattern matches a
1926        single file. Field splitting is not performed.
1927 
1928 
1929        In each of the following redirections, if file is of the form
1930        /dev/sctp/host/port, /dev/tcp/host/port, or /dev/udp/host/port, where
1931        host is a hostname or host address, and port is a service specified by
1932        name or an integer port number, then the redirection attempts to make a
1933        tcp, sctp or udp connection to the corresponding socket.
1934 
1935 
1936        No intervening space is allowed between the characters of redirection
1937        operators.
1938 
1939        <word
1940                      Use file word as standard input (file descriptor 0).
1941 
1942 
1943        >word
1944                      Use file word as standard output (file descriptor 1). If
1945                      the file does not exist then it is created. If the file
1946                      exists, and the noclobber option is on, this causes an
1947                      error. Otherwise, it is truncated to zero length.
1948 
1949 
1950        >|word
1951                      Same as >,      except that it overrides the noclobber option.
1952 
1953 
1954        >;word
1955                      Write output to a temporary file.  If the command
1956                      completes successfully rename it to word, otherwise,
1957                      delete the temporary file.  >;word      cannot be used with
1958                      the exec(2) built-in.
1959 
1960 
1961        >>word
1962                      Use file word as standard output. If the file exists,
1963                      then output is appended to it (by first seeking to the
1964                      end-of-file). Otherwise, the file is created.
1965 
1966 
1967        <>word
1968                      Open file word for reading and writing as standard input.
1969 
1970 
1971        <<[-]word
1972                      The shell input is read up to a line that is the same as
1973                      word after any quoting has been removed, or to an end-of-
1974                      file. No parameter substitution, command substitution,
1975                      arithmetic substitution or file name generation is
1976                      performed on word. The resulting document, called a here-
1977                      document, becomes the standard input. If any character of
1978                      word is quoted, then no interpretation is placed upon the
1979                      characters of the document. Otherwise, parameter
1980                      expansion, command substitution, and arithmetic
1981                      substitution occur, \NEWLINE is ignored, and \ must be
1982                      used to quote the characters \, $, `. If - is appended to
1983                      <<, then all leading tabs are stripped from word and from
1984                      the document. If # is appended to <<, then   leading SPACEs
1985                      and TABs are stripped off the first line of the document
1986                      and up to an equivalent indentation is stripped from the
1987                      remaining lines and from word. A tab stop is assumed to
1988                      occur at every 8 columns for the purposes of determining
1989                      the indentation.
1990 
1991 
1992        <<<word
1993                      A short form of here document in which word becomes the
1994                      contents of the here-document after any parameter
1995                      expansion, command substitution, and arithmetic
1996                      substitution occur.
1997 
1998 
1999        <&digit
2000                      The standard input is duplicated from file descriptor
2001                      digit, and similarly for the standard output using
2002                      >&digit. See dup(2).
2003 
2004 
2005        <&digit-
2006                      The file descriptor specified by digit is moved to
2007                      standard input.  Similarly for the standard output using
2008                      >&digit-.
2009 
2010 
2011        <&-
2012                      The standard input is closed. Similarly for the standard
2013                      output using >&-.
2014 
2015 
2016        <&p
2017                      The input from the co-process is moved to standard input.
2018 
2019 
2020        >&p
2021                      The output to the co-process is moved to standard output.
2022 
2023 
2024        <#((expr))
2025                      Evaluate arithmetic expression expr and position file
2026                      descriptor 0 to the resulting value bytes from the start
2027                      of the file. The variables CUR and EOF evaluate to the
2028                      current offset and end-of-file offset respectively when
2029                      evaluating expr.
2030 
2031 
2032        >#((expr))
2033                      The same as <# except applies to file descriptor 1.
2034 
2035 
2036        <#pattern
2037                      Seek forward to the beginning of the next line containing
2038                      pattern.
2039 
2040 
2041        <##pattern
2042                      The same as <#, except that the portion of      the file that
2043                      is skipped is copied to standard output.
2044 
2045 
2046 
2047        If one of the redirection operators is preceded by a digit, with no
2048        intervening space, then the file descriptor number referred to is that
2049        specified by the digit (instead of the default 0 or 1). If one of the
2050        redirection operators other than >&- and  the ># and <# forms, is
2051        preceded by {varname} with no intervening space, then a file descriptor
2052        number >      10 is selected by the shell and stored in the variable
2053        varname. If >&- or the any of the ># and       <# forms is preceded by
2054        {varname} the value of varname defines the file descriptor to close or
2055        position. For example:
2056 
2057          ... 2>&1
2058 
2059 
2060 
2061 
2062        means file descriptor 2 is to be opened for writing as a duplicate of
2063        file descriptor 1 and
2064 
2065          exec [n]<file
2066 
2067 
2068 
2069 
2070        means open file for reading and store the file descriptor number in
2071        variable n. The order in which redirections are specified is
2072        significant.  The shell evaluates each redirection in terms of the
2073        (file_descriptor, file) association at the time of evaluation. For
2074        example:
2075 
2076          ... 1>fname 2>&1
2077 
2078 
2079 
2080 
2081        first associates file descriptor 1 with file fname. It then associates
2082        file descriptor 2 with the file associated with file descriptor 1, that
2083        is, fname. If the order of redirections were reversed, file descriptor
2084        2 would be associated with the terminal (assuming file descriptor 1 had
2085        been) and then file descriptor 1 would be associated with file fname.
2086        If a command is followed by & and job control is     not active, the
2087        default standard input for the command is the empty file /dev/null.
2088        Otherwise, the environment for the execution of a command contains the
2089        file descriptors of the invoking shell as modified by input and output
2090        specifications.
2091 
2092    Environment
2093        The environment is a list of name-value pairs that is passed to an
2094        executed program in the same way as a normal argument list. See
2095        environ(5).
2096 
2097 
2098        The names must be identifiers and the values are character strings. The
2099        shell interacts with the environment in several ways. On invocation,
2100        the shell scans the environment and creates a variable for each name
2101        found, giving it the corresponding value and attributes and marking it
2102        export. Executed commands inherit the environment. If the user modifies
2103        the values of these variables or creates new ones, using the export or
2104        typeset -x commands, they become part of the environment. The
2105        environment seen by any executed command is thus composed of any name-
2106        value pairs originally inherited by the shell, whose values can be
2107        modified by the current shell, plus any additions which must be noted
2108        in export or typeset -x commands. The environment for any simple-
2109        command or function can be augmented by prefixing it with one or more
2110        variable assignments. A variable assignment argument is a word of the
2111        form identifier=value. Thus:
2112 
2113          TERM=450 cmd args
2114 
2115 
2116 
2117 
2118        and
2119 
2120          (export TERM; TERM=450; cmd args)
2121 
2122 
2123 
2124 
2125        are equivalent (as far as the execution of cmd is concerned except for
2126        special built-in commands listed in the Built-Ins section, those that
2127        are preceded with a dagger. If the obsolete -k option is set, all
2128        variable assignment arguments are placed in the environment, even if
2129        they occur after the command name.
2130 
2131 
2132        The following example first prints a=b c and then c:
2133 
2134          echo a=b c
2135          set -k
2136          echo a=b c
2137 
2138 
2139 
2140 
2141        This feature is intended for use with scripts written for early
2142        versions of the shell and its use in new scripts is strongly
2143        discouraged.
2144 
2145    Functions
2146        For historical reasons, there are two ways to define functions, the
2147        name() syntax and the function name syntax. These are described in the
2148        Commands section of this manual page.
2149 
2150 
2151        Shell functions are read in and stored internally. Alias names are
2152        resolved when the function is read. Functions are executed like
2153        commands with the arguments passed as positional parameters. See the
2154        Execution section of this manual page for details.
2155 
2156 
2157        Functions defined by the function name syntax and called by name
2158        execute in the same process as the caller and share all files and
2159        present working directory with the caller. Traps caught by the caller
2160        are reset to their default action inside the function. A trap condition
2161        that is not caught or ignored by the function causes the function to
2162        terminate and the condition to be passed on to the caller. A trap on
2163        EXIT set inside a function is executed in the environment of the caller
2164        after the function completes.  Ordinarily, variables are shared between
2165        the calling program and the function.  However, the typeset special
2166        built-in command used within a function defines local variables whose
2167        scope includes the current function. They can be passed to functions
2168        that they call in the variable assignment list that precedes the call
2169        or as arguments passed as name references. Errors within functions
2170        return control to the caller.
2171 
2172 
2173        Functions defined with the name() syntax and functions defined with the
2174        function name syntax that are invoked with the . special built-in are
2175        executed in the caller's environment and share all variables and traps
2176        with the caller. Errors within these function executions cause the
2177        script that contains them to abort.
2178 
2179 
2180        The special built-in command return is used to return from function
2181        calls.
2182 
2183 
2184        Function names can be listed with the -f or +f option of the typeset
2185        special built-in command. The text of functions, when available, is
2186        also listed with -f. Functions can be undefined with the -f option of
2187        the unset special built-in command.
2188 
2189 
2190        Ordinarily, functions are unset when the shell executes a shell script.
2191        Functions that need to be defined across separate invocations of the
2192        shell should be placed in a directory and the FPATH variable should
2193        contain the name of this directory. They can also be specified in the
2194        ENV file.
2195 
2196    Discipline Functions
2197        Each variable can have zero or more discipline functions associated
2198        with it.  The shell initially understands the discipline names get,
2199        set, append, and unset but on most systems others can be added at run
2200        time via the C programming interface extension provided by the builtin
2201        built-in utility. If the get discipline is defined for a variable, it
2202        is invoked whenever the specified variable is referenced. If the
2203        variable .sh.value is assigned a value inside the discipline function,
2204        the referenced variable is evaluated to this value instead. If the set
2205        discipline is defined for a variable, it is invoked whenever the
2206        specified variable is assigned a value. If the append discipline is
2207        defined for a variable, it is invoked whenever a value is appended to
2208        the specified variable.  The variable .sh.value is specified the value
2209        of the variable before invoking the discipline, and the variable is
2210        assigned the value of .sh.value after the discipline completes. If
2211        .sh.value is unset inside the discipline, then that value is unchanged.
2212        If the unset discipline is defined for a variable, it is invoked
2213        whenever the specified variable is unset. The variable is not unset
2214        unless it is unset explicitly from within this discipline function.
2215 
2216 
2217        The variable .sh.name contains the name of the variable for which the
2218        discipline function is called, .sh.subscript is the subscript of the
2219        variable, and .sh.value contains the value being assigned inside the
2220        set discipline function. For the set discipline, changing .sh.value
2221        changes the value that gets assigned.  The variable _ is a reference to
2222        the variable including the subscript if any. For the set discipline,
2223        changing .sh.value will change the value that gets assigned. Finally,
2224        the expansion ${ var.name}, when name is the name of a discipline, and
2225        there is no variable of this name, is equivalent to the command
2226        substitution ${var.name;}.
2227 
2228 
2229    Name Spaces
2230        Commands and functions that are executed as part of the list of a
2231        namespace command that modify variables or create new ones, create a
2232        new variable whose name is the name of the name space as given by
2233        identifier preceded by two dots (..).  When a variable whose name is
2234        name is referenced, it is first searched for using .identifier.name.
2235        Similarly, a function defined by a command in the namespace list is
2236        created using the name space name preceded by two dots (..).
2237 
2238        When  the list of a namespace command contains a namespace command, the
2239        names of variables and functions that are created consist of the
2240        variable or function name preceded by the list of identifiers each
2241        preceded by two dots (..).
2242 
2243        Outside of a name space, a variable or function created inside a name
2244        space can be referenced by preceding it with the name space name.
2245 
2246        By default, variables staring with .sh are in the sh name space.
2247 
2248 
2249    Typed Variables
2250        Typed variables provide a way to create data structure and objects. A
2251        type can be defined either by a shared library, by the enum built-in
2252        command described below, or by using the new -T option of the typeset
2253        built-in command. With the -T option of typeset, the type name,
2254        specified as an option argument to -T, is set with a compound variable
2255        assignment that defines the type. Function definitions can appear
2256        inside the compound variable assignment and these become discipline
2257        functions for this type and can be invoked or redefined by each
2258        instance of the type. The function name create is treated specially. It
2259        is invoked for each instance of the type that is created but is not
2260        inherited and cannot be redefined for each instance.
2261 
2262        When a type is defined a special built-in command of that name is
2263        added.  These built-ins are declaration commands and follow the same
2264        expansion rules as all the special built-in commands defined below that
2265        are preceded by a dot (.). These commands can subsequently be used
2266        inside further type definitions. The man page for these commands can be
2267        generated by using the --man option or any of the other -- options
2268        described with getopts. The -r, -a, -A, -h and -S options of typeset
2269        are permitted with each of these new built-ins.
2270 
2271        An instance of a type is created by invoking the type name followed by
2272        one or more instance names.  Each instance of the type is initialized
2273        with a copy of the sub-variables except for sub-variables that are
2274        defined with the -s option. Variables defined with -S are shared by all
2275        instances of the type. Each instance can change the value of any sub-
2276        variable and can also define new discipline functions of the same names
2277        as those defined by the type definition as well as any standard
2278        discipline names. No additional sub-variables can be defined for any
2279        instance.
2280 
2281        When defining a type, if the value of a sub-variable is not set and the
2282        -r attribute is specified, it causes the sub-variable to be a required
2283        sub-variable. Whenever an instance of a type is created, all required
2284        sub-variables must be specified. These sub-variables become readonly in
2285        each instance.
2286 
2287        When unset is invoked on a sub-variable within a type, and the -r
2288        attribute has not been specified for this field, the value is reset to
2289        the default value associative with the type. Invoking unset on a type
2290        instance not contained within another type deletes all sub-variables
2291        and the variable itself.
2292 
2293        A type definition can be derived from another type definition by
2294        defining the first sub-variable name as _ and defining its type as the
2295        base type. Any remaining definitions will be additions and
2296        modifications that apply to the new type. If the new type name is the
2297        same is that of the base type, the type will be replaced and the
2298        original type will no longer be accessible.
2299 
2300        The typeset command with -T and no option argument or operands will
2301        write all the type definitions to standard output in a form that that
2302        can be read in to create all the types.
2303 
2304 
2305    Jobs
2306        If the monitor option of the set command is turned on, an interactive
2307        shell associates a job with each pipeline. It keeps a table of current
2308        jobs, printed by the jobs command, and assigns them small integer
2309        numbers. When a job is started asynchronously with &, the shell prints
2310        a line which looks like:
2311 
2312          [1] 1234
2313 
2314 
2315 
2316 
2317        indicating that the job which was started asynchronously was job number
2318        1 and had one (top-level) process, whose process id was 1234.
2319 
2320 
2321        If you are running a job and wish to stop it, CTRL-z sends a STOP
2322        signal to the current job. The shell normally displays a message that
2323        the job has been stopped, and displays another prompt. You can then
2324        manipulate the state of this job, putting it in the background with the
2325        bg command, or run some other commands and then eventually bring the
2326        job back into the foreground with the foreground command fg. A CTRL-z
2327        takes effect immediately and is like an interrupt in that pending
2328        output and unread input are discarded when it is typed.
2329 
2330 
2331        A job being run in the background stops if it tries to read from the
2332        terminal.  Background jobs are normally allowed to produce output, but
2333        this can be disabled by giving the command sttytostop. If you set this
2334        tty option, then background jobs stop when they try to produce output
2335        like they do when they try to read input.
2336 
2337 
2338        A job pool is a collection of jobs started with list & associated with
2339        a name.
2340 
2341 
2342        There are several ways to refer to jobs in the shell. A job can be
2343        referred to by the process id of any process of the job or by one of
2344        the following:
2345 
2346        %number
2347                    The job with the specified number.
2348 
2349 
2350        pool
2351                    All the jobs in the job pool named by pool.
2352 
2353 
2354        pool.number
2355                    The job number number in the pool named by pool.
2356 
2357 
2358        %string
2359                    Any job whose command line begins with string.
2360 
2361 
2362        %?string
2363                    Any job whose command line contains string.
2364 
2365 
2366        %%
2367                    Current job.
2368 
2369 
2370        %+
2371                    Equivalent to %%.
2372 
2373 
2374        %-
2375                    Previous job.
2376 
2377 
2378        In addition, unless noted otherwise, wherever a job can be specified,
2379        the name of a background job pool can be used to represent all the jobs
2380        in that pool.
2381 
2382 
2383 
2384        The shell learns immediately whenever a process changes state. It
2385        normally informs you whenever a job becomes blocked so that no further
2386        progress is possible, but only just before it prints a prompt. This is
2387        done so that it does not otherwise disturb your work. The notify option
2388        of the set command causes the shell to print these job change messages
2389        as soon as they occur.
2390 
2391 
2392        When the monitor option is on, each background job that completes
2393        triggers any trap set for CHLD.
2394 
2395 
2396        When you try to leave the shell while jobs are running or stopped, you
2397        are warned that You have stopped(running) jobs. You can use the jobs
2398        command to see what they are. If you immediately try to exit again, the
2399        shell does not warn you a second time, and the stopped jobs are
2400        terminated. When a login shell receives a HUP signal, it sends a HUP
2401        signal to each job that has not been disowned with the disown built-in
2402        command.
2403 
2404    Signals
2405        The INT and QUIT signals for an invoked command are ignored if the
2406        command is followed by &     and the monitor option is not active.
2407        Otherwise, signals have the values inherited by the shell from its
2408        parent. See the trap built-in command.
2409 
2410    Execution
2411        Each time a command is read, the substitutions are carried out. If the
2412        command name matches one of the ones in the Special Built-in Commands
2413        section of this manual page, it is executed within the current shell
2414        process. Next, the command name is checked to see if it matches a user
2415        defined function. If it does, the positional parameters are saved and
2416        then reset to the arguments of the function call. A function is also
2417        executed in the current shell process.  When the function completes or
2418        issues a return, the positional parameter list is restored. For
2419        functions defined with the function name syntax, any trap set on EXIT
2420        within the function is executed. The exit value of a function is the
2421        value of the last command executed. If a command name is not a special
2422        built-in command or a user defined function, but it is one of the
2423        built-in commands, it is executed in the current shell process.
2424 
2425 
2426        The shell variables PATH and FPATH define the search path for the
2427        directory containing the command. Alternative directory names are
2428        separated by a colon (:). The default path is /bin:/usr/bin:,
2429        specifying /bin, /usr/bin, and the current directory in that order. The
2430        current directory can be specified by two or more adjacent colons, or
2431        by a colon at the beginning or end of the path list. If the command
2432        name contains a slash (/), the search path is not used. Otherwise, each
2433        directory in the list of directories defined by PATH and FPATH is
2434        checked in order.  If the directory being searched is contained in the
2435        value of the FPATH variable and contains a file whose name matches the
2436        command being searched, then this file is loaded into the current shell
2437        environment as if it were the argument to the . command except that
2438        only preset aliases are expanded, and a function of the specified name
2439        is executed as described in this manual page.
2440 
2441 
2442        If this directory is not in FPATH, the shell first determines whether
2443        there is a built-in version of a command corresponding to a given
2444        pathname and, if so, it is invoked in the current process. If no built-
2445        in is found, the shell checks for a file named .paths in this
2446        directory. If found and there is a line of the form:
2447 
2448          FPATH=path
2449 
2450        where path is an existing directory, then that directory is searched
2451        immediately after the current directory as if it were found in the
2452        FPATH variable. If path does not begin with /, it is checked for
2453        relative to the directory being searched.
2454 
2455 
2456        The .paths file is then checked for a line of the form:
2457 
2458          PLUGIN_LIB=libname [ : libname ] ...
2459 
2460        Each library named by libname will be searched for as if it were an
2461        option argument to builtin -f and, if it contains a built-in of the
2462        specified name, this is executed instead of a command by this name.
2463 
2464 
2465        Any built-in loaded from a library found this way will be associated
2466        with the directory containing the .paths file so it will only execute
2467        if not found in an earlier directory.
2468 
2469 
2470        Finally, the directory will be checked for a file of the given name.
2471        If the file has execute permission but is not an a.out file, it is
2472        assumed to be a file containing shell commands. A separate shell is
2473        spawned to read it. All non-exported variables are removed in this
2474        case. If the shell command file doesn't have read permission, and/or if
2475        the setuid and setgid bits are set on the file, then the shell executes
2476        an agent whose job it is to set up the permissions and execute the
2477        shell with the shell command file passed down as an open file.
2478 
2479        If the .paths contains a line of the form:
2480 
2481          name=value
2482 
2483        in the first or second line, then the environment variable name is
2484        modified by prepending the directory specified by value to the
2485        directory list. If value is not an absolute directory, then it
2486        specifies a directory relative to the directory in which the executable
2487        was found. If the environment variable name does not already exist it
2488        will be added to the environment list for the specified command.
2489 
2490        A parenthesized command is executed in a sub-shell without removing
2491        non-exported variables.
2492 
2493 
2494    Command Re-entry
2495        The text of the last HISTSIZE (default 512) commands entered from a
2496        terminal device is saved in a history file. The file $HOME/.sh_history
2497        is used if the HISTFILE variable is not set or if the file it names is
2498        not writable. A shell can access the commands of all interactive shells
2499        which use the same named HISTFILE. The built-in command hist is used to
2500        list or edit a portion of this file. The portion of the file to be
2501        edited or listed can be selected by number or by giving the first
2502        character or characters of the command. A single command or range of
2503        commands can be specified. If you do not specify an editor program as
2504        an argument to hist then the value of the variable HISTEDIT is used. If
2505        HISTEDIT is unset, the obsolete variable FCEDIT is used. If FCEDIT is
2506        not defined, then /bin/ed is used. The edited commands are printed and
2507        executed again upon leaving the editor unless you quit without writing.
2508        The -s option (and in obsolete versions, the editor name -) is used to
2509        skip the editing phase and to re-execute the command. In this case a
2510        substitution parameter of the form old=newcan be used to modify the
2511        command before execution. For example, with the preset alias r, which
2512        is aliased to 'hist -s', typing `r bad=good c' re-executes the most
2513        recent command which starts with the letter c, replacing the first
2514        occurrence of the string bad with the string good.
2515 
2516    Inline Editing Options
2517        Normally, each command line entered from a terminal device is simply
2518        typed followed by a NEWLINE (RETURN or LINE FEED). If either the emacs,
2519        gmacs, or vi option is active, the user can edit the command line.  To
2520        be in either of these edit modes set the corresponding option. An
2521        editing option is automatically selected each time the VISUAL or EDITOR
2522        variable is assigned a value ending in either of these option names.
2523 
2524 
2525        The editing features require that the user's terminal accept RETURN as
2526        carriage return without line feed and that a SPACE must overwrite the
2527        current character on the screen.
2528 
2529 
2530        Unless the multiline option is on, the editing modes implement a
2531        concept where the user is looking through a window at the current line.
2532        The window width is the value of COLUMNS if it is defined, otherwise
2533        80. If the window width is too small to display the prompt and leave at
2534        least 8 columns to enter input, the prompt is truncated from the left.
2535        If the line is longer than the window width minus two, a mark is
2536        displayed at the end of the window to notify the user. As the cursor
2537        moves and reaches the window boundaries the window is centered about
2538        the cursor. The mark is a > (<, *) if the line extends on the right ,
2539        left, or both sides of the window.
2540 
2541 
2542        The search commands in each edit mode provide access to the history
2543        file. Only strings are matched, not patterns, although a leading ^ in
2544        the string restricts the match to begin at the first character in the
2545        line.
2546 
2547 
2548        Each of the edit modes has an operation to list the files or commands
2549        that match a partially entered word. When applied to the first word on
2550        the line, or the first word after a ;, |, &, or (, and the word does
2551        not begin with ~ or contain a /, the list of aliases, functions, and
2552        executable commands defined by the PATH variable that could match the
2553        partial word is displayed. Otherwise, the list of files that match the
2554        specified word is displayed. If the partially entered word does not
2555        contain any file expansion characters, a * is appended before
2556        generating these lists.  After displaying the generated list, the input
2557        line is redrawn. These operations are called command name listing and
2558        file name listing, respectively.  There are additional operations,
2559        referred to as command name completion and file name completion, which
2560        compute the list of matching commands or files, but instead of printing
2561        the list, replace the current word with a complete or partial match.
2562        For file name completion, if the match is unique, a / is appended if
2563        the file is a directory and a space is appended if the file is not a
2564        directory. Otherwise, the longest common prefix for all the matching
2565        files replaces the word. For command name completion, only the portion
2566        of the file names after the last / are used to find the longest command
2567        prefix. If only a single name matches this prefix, then the word is
2568        replaced with the command name followed by a space. When using a TAB
2569        for completion that does not yield a unique match, a subsequent TAB
2570        provides a numbered list of matching alternatives. A specific selection
2571        can be made by entering the selection number followed by a TAB.
2572 
2573    Key Bindings
2574        The KEYBD trap can be used to intercept keys as they are typed and
2575        change the characters that are actually seen by the shell. This trap is
2576        executed after each character (or sequence of characters when the first
2577        character is ESC) is entered while reading from a terminal.
2578 
2579 
2580        The variable .sh.edchar contains the character or character sequence
2581        which generated the trap. Changing the value of .sh.edchar in the trap
2582        action causes the shell to behave as if the new value were entered from
2583        the keyboard rather than the original value. The variable .sh.edcol is
2584        set to the input column number of the cursor at the time of the input.
2585        The variable .sh.edmode is set to ESC when in vi insert mode and is
2586        null otherwise. By prepending ${.sh.editmode} to a value assigned to
2587        .sh.edchar it causes the shell to change to control mode if it is not
2588        already in this mode.
2589 
2590 
2591        This trap is not invoked for characters entered as arguments to editing
2592        directives, or while reading input for a character search.
2593 
2594    emacs Editing Mode
2595        This mode is entered by enabling either the emacs or gmacs option.  The
2596        only difference between these two modes is the way they handle ^T. To
2597        edit, the user moves the cursor to the point needing correction and
2598        then inserts or deletes characters or words as needed. All the editing
2599        commands are control characters or escape sequences. The notation for
2600        control characters is caret (^) followed by the character.
2601 
2602 
2603        For example, ^F is the notation for CTRL/F. This is entered by
2604        depressing f while holding down the CTRL (control) key. The SHIFT key
2605        is not depressed. (The notation ^? indicates the DEL (delete) key.)
2606 
2607 
2608        The notation for escape sequences is M- followed by a character. For
2609        example, M-f (pronounced Meta f) is entered by depressing ESC (ASCII
2610        033) followed by f. M-F is the notation for ESC followed by F.
2611 
2612 
2613        All edit commands operate from any place on the line, not just at the
2614        beginning. The RETURN or the LINE FEED key is not entered after edit
2615        commands except when noted.
2616 
2617        ^F
2618                     Move the cursor forward (right) one character.
2619 
2620 
2621        M-[C
2622                     Move the cursor forward (right) one character.
2623 
2624 
2625        M-f
2626                     Move the cursor forward one word. The emacs editor's idea
2627                     of a word is a string of characters consisting of only
2628                     letters, digits and underscores.
2629 
2630 
2631        ^B
2632                     Move the cursor backward (left) one character.
2633 
2634 
2635        M-[D
2636                     Move the cursor backward (left) one character.
2637 
2638 
2639        M-b
2640                     Move the cursor backward one word.
2641 
2642 
2643        ^A
2644                     Move the cursor to the beginning of the line.
2645 
2646 
2647        M-[H
2648                     Move the cursor to the beginning of the line.
2649 
2650 
2651        ^E
2652                     Move the cursor to the end of the line.
2653 
2654 
2655        M-[Y
2656                     Move the cursor to the end of line.
2657 
2658 
2659        ^]char
2660                     Move the cursor forward to the character char on the
2661                     current line.
2662 
2663 
2664        M-^]char
2665                     Move the cursor backwards to the character char on the
2666                     current line.
2667 
2668 
2669        ^X^X
2670                     Interchange the cursor and the mark.
2671 
2672 
2673        erase
2674                     Delete the previous character. The user-defined erase
2675                     character is defined by the stty(1) command, and is
2676                     usually ^H or #.
2677 
2678 
2679        lnext
2680                     Removes the next character's editing features. The user-
2681                     defined literal next character is defined by the stty(1)
2682                     command, or is ^V if not defined.
2683 
2684 
2685        ^D
2686                     Delete the current character.
2687 
2688 
2689        M-d
2690                     Delete the current word.
2691 
2692 
2693        M-^H
2694                     MetaBACKSPACE. Delete the previous word.
2695 
2696 
2697        M-h
2698                     Delete the previous word.
2699 
2700 
2701        M-^?
2702                     MetaDEL. Delete the previous word. If your interrupt
2703                     character is ^? (DEL, the default), this command does not
2704                     work.
2705 
2706 
2707        ^T
2708                     Transpose the current character with the previous
2709                     character, and advance the cursor in emacs mode. Transpose
2710                     two previous characters in gmacs mode.
2711 
2712 
2713        ^C
2714                     Capitalize the current character.
2715 
2716 
2717        M-c
2718                     Capitalize the current word.
2719 
2720 
2721        M-l
2722                     Change the current word to lower case.
2723 
2724 
2725        ^K
2726                     Delete from the cursor to the end of the line. If preceded
2727                     by a numerical parameter whose value is less than the
2728                     current cursor position, delete from specified position up
2729                     to the cursor. If preceded by a numerical parameter whose
2730                     value is greater than the current cursor position, then
2731                     delete from cursor up to specified cursor position.
2732 
2733 
2734        ^W
2735                     Kill from the cursor to the mark.
2736 
2737 
2738        M-p
2739                     Push the region from the cursor to the mark on the stack.
2740 
2741 
2742        kill
2743                     Kill the entire current line. The user-defined kill
2744                     character is defined by the stty(1) command, usually a ^G
2745                     or @. If two kill characters are entered in succession,
2746                     all kill characters from then on cause a line feed.  This
2747                     is useful when using paper terminals.
2748 
2749 
2750        ^Y
2751                     Restore the last item removed from line. Yank the item
2752                     back to the line.
2753 
2754 
2755        ^L
2756                     Line feed and print the current line.
2757 
2758 
2759        M-^L
2760                     Clear the screen.
2761 
2762 
2763        ^@
2764                     Null character. Set mark.
2765 
2766 
2767        M-space
2768                     MetaSPACE. Set the mark.
2769 
2770 
2771        ^J
2772                     New line. Execute the current line.
2773 
2774 
2775        ^M
2776                     Return. Execute the current line.
2777 
2778 
2779        EOF
2780                     End-of-file character, normally ^D, is processed as an
2781                     end-of-file only if the current line is null.
2782 
2783 
2784        ^P
2785                     Fetch the previous command. Each time ^P is entered the
2786                     previous command back in time is accessed. Moves back one
2787                     line when it is not on the first line of a multi-line
2788                     command.
2789 
2790 
2791        M-[A
2792                     Equivalent to ^P.
2793 
2794 
2795        M-<
2796                     Fetch the least recent (oldest) history line.
2797 
2798 
2799        M->
2800                     Fetch the most recent (youngest) history line.
2801 
2802 
2803        ^N
2804                     Fetch the next command line. Each time ^N is entered the
2805                     next command line forward in time is accessed.
2806 
2807 
2808        M-[B
2809                     Equivalent to ^N.
2810 
2811 
2812        ^Rstring
2813                     Reverse search history for a previous command line
2814                     containing string. If a parameter of zero is specified,
2815                     the search is forward. string is terminated by a RETURN or
2816                     NEWLINE. If string is preceded by a ^, the matched line
2817                     must begin with string. If string is omitted, then the
2818                     next command line containing the most recent string is
2819                     accessed. In this case a parameter of zero reverses the
2820                     direction of the search.
2821 
2822 
2823        ^O
2824                     Operate. Execute the current line and fetch the next line
2825                     relative to current line from the history file.
2826 
2827 
2828        M-digits
2829                     Escape. Define numeric parameter. The digits are taken as
2830                     a parameter to the next command. The commands that accept
2831                     a parameter are: ^F, ^B, ERASE, ^C, ^D, ^K, ^R, ^P, ^N,
2832                     ^], M-., M-, M-^], M-_, M-=, M-b, M-c, M-d, M-f, M-h, M-l,
2833                     and M-^H.
2834 
2835 
2836        M-letter
2837                     Soft-key. Search the alias list for an alias by the name
2838                     letter. If an alias of letter is defined, insert its value
2839                     on the input queue.  letter must not be one of the
2840                     metafunctions in this section.
2841 
2842 
2843        M-[letter
2844                     Soft key. Search the alias list for an alias by the name
2845                     letter. If an alias of this name is defined, insert its
2846                     value on the input queue. This can be used to program
2847                     function keys on many terminals.
2848 
2849 
2850        M-.
2851                     The last word of the previous command is inserted on the
2852                     line. If preceded by a numeric parameter, the value of
2853                     this parameter determines which word to insert rather than
2854                     the last word.
2855 
2856 
2857        M-_
2858                     Same as M-..
2859 
2860 
2861        M-*
2862                     Attempt filename generation on the current word. As
2863                     asterisk is appended if the word does not match any file
2864                     or contain any special pattern characters.
2865 
2866 
2867        M-ESC
2868                     Command or file name completion as described in this
2869                     manual page.
2870 
2871 
2872        ^ITAB
2873                     Attempts command or file name completion as described in
2874                     this manual page. If a partial completion occurs,
2875                     repeating this behaves as if M-= were entered.  If no
2876                     match is found or entered after SPACE, a TAB is inserted.
2877 
2878 
2879        M-=
2880                     If not preceded by a numeric parameter, generates the list
2881                     of matching commands or file names as described in this
2882                     manual page. Otherwise, the word under the cursor is
2883                     replaced by the item corresponding to the value of the
2884                     numeric parameter from the most recently generated command
2885                     or file list. If the cursor is not on a word, the word is
2886                     inserted instead.
2887 
2888 
2889        ^U
2890                     Multiply parameter of next command by 4.
2891 
2892 
2893        \
2894                     Escape the next character. Editing characters, the user's
2895                     erase, kill and interrupt (normally ^?) characters can be
2896                     entered in a command line or in a search string if
2897                     preceded by a \. The \ removes the next character's
2898                     editing features, if any.
2899 
2900 
2901        M-^V
2902                     Display the version of the shell.
2903 
2904 
2905        M-#
2906                     If the line does not begin with a #, a # is inserted at
2907                     the beginning of the line and after each NEWLINE, and the
2908                     line is entered. This causes a comment to be inserted in
2909                     the history file. If the line begins with a #, the # is
2910                     deleted and one # after each NEWLINE is also deleted.
2911 
2912 
2913    vi Editing Mode
2914        There are two typing modes. Initially, when you enter a command you are
2915        in the input mode. To edit, the user enters control mode by typing ESC
2916        (033) and moves the cursor to the point needing correction and then
2917        inserts or deletes characters or words as needed. Most control commands
2918        accept an optional repeat count prior to the command.
2919 
2920 
2921        When in vi mode on most systems, canonical processing is initially
2922        enabled and the command is echoed again if the speed is 1200 baud or
2923        greater and it contains any control characters or less than one second
2924        has elapsed since the prompt was printed. The ESC character terminates
2925        canonical processing for the remainder of the command and the user can
2926        then modify the command line. This scheme has the advantages of
2927        canonical processing with the type-ahead echoing of raw mode.
2928 
2929 
2930        If the option viraw is also set, the terminal is always have canonical
2931        processing disabled. This mode is implicit for systems that do not
2932        support two alternate end of line delimiters, and might be helpful for
2933        certain terminals.
2934 
2935    Input Edit Commands
2936        By default the editor is in input mode.
2937 
2938 
2939        The following input edit commands are supported:
2940 
2941        ERASE
2942                  User defined erase character as defined by the stty command,
2943                  usually ^H or #. Delete previous character.
2944 
2945 
2946        ^W
2947                  Delete the previous blank separated word. On some systems the
2948                  viraw option might be required for this to work.
2949 
2950 
2951        EOF
2952                  As the first character of the line causes the shell to
2953                  terminate unless the ignoreeof option is set. Otherwise this
2954                  character is ignored.
2955 
2956 
2957        lnext
2958                  User defined literal next character as defined by the stty(1)
2959                  or ^V if not defined. Removes the next character's editing
2960                  features, if any. On some systems the viraw option might be
2961                  required for this to work.
2962 
2963 
2964        \
2965                  Escape the next ERASE or KILL character.
2966 
2967 
2968        ^I TAB
2969                  Attempts command or file name completion as described in this
2970                  manual page and returns to input mode. If a partial
2971                  completion occurs, repeating this behaves as if = were
2972                  entered from control mode. If no match is found or entered
2973                  after SPACE, a TAB is inserted.
2974 
2975 
2976    Motion Edit Commands
2977        The motion edit commands move the cursor.
2978 
2979 
2980        The following motion edit commands are supported:
2981 
2982        [count]l
2983                     Move the cursor forward (right) one character.
2984 
2985 
2986        [count][C
2987                     Move the cursor forward (right) one character.
2988 
2989 
2990        [count]w
2991                     Move the cursor forward one alphanumeric word.
2992 
2993 
2994        [count]W
2995                     Move the cursor to the beginning of the next word that
2996                     follows a blank.
2997 
2998 
2999        [count]e
3000                     Move the cursor to the end of the word.
3001 
3002 
3003        [count]E
3004                     Move the cursor to the end of the current blank delimited
3005                     word.
3006 
3007 
3008        [count]h
3009                     Move the cursor backward (left) one character.
3010 
3011 
3012        [count][D
3013                     Move the cursor backward (left) one character.
3014 
3015 
3016        [count]b
3017                     Move the cursor backward one word.
3018 
3019 
3020        [count]B
3021                     Move the cursor to the preceding blank separated word.
3022 
3023 
3024        [count]|
3025                     Move the cursor to column count.
3026 
3027 
3028        [count]fc
3029                     Find the next character c in the current line.
3030 
3031 
3032        [count]Fc
3033                     Find the previous character c in the current line.
3034 
3035 
3036        [count]tC
3037                     Equivalent to f followed by h.
3038 
3039 
3040        [count]Tc
3041                     Equivalent to F followed by l.
3042 
3043 
3044        [count];
3045                     Repeat count times the last single character find command:
3046                     f, F, t, or T.
3047 
3048 
3049        [count],
3050                     Reverse the last single character find command count
3051                     times.
3052 
3053 
3054        0
3055                     Move the cursor to the start of line.
3056 
3057 
3058        ^
3059                     Move the cursor to start of line.
3060 
3061 
3062        [H
3063                     Move the cursor to the first non-blank character in the
3064                     line.
3065 
3066 
3067        $
3068                     Move the cursor to the end of the line.
3069 
3070 
3071        [Y
3072                     Move the cursor to the end of the line.
3073 
3074 
3075        %
3076                     Moves to balancing (, ), {, }, [, or ]. If cursor is not
3077                     on one of the characters described in this section, the
3078                     remainder of the line is searched for the first occurrence
3079                     of one of the characters first.
3080 
3081 
3082    Search Edit Commands
3083        The search edit commands access your command history.
3084 
3085 
3086        The following search edit commands are supported:
3087 
3088        [count]k
3089                     Fetch the previous command. Each time k is entered, the
3090                     previous command back in time is accessed.
3091 
3092 
3093        [count]-
3094                     Fetch the previous command. Each time k is entered, the
3095                     previous command back in time is accessed.
3096 
3097                     Equivalent to k.
3098 
3099 
3100        [count][A
3101                     Fetch the previous command. Each time k is entered, the
3102                     previous command back in time is accessed.
3103 
3104                     Equivalent to k.
3105 
3106 
3107        [count]j
3108                     Fetch the next command. Each time j is entered, the next
3109                     command forward in time is accessed.
3110 
3111 
3112        [count]+
3113                     Fetch the next command. Each time j is entered, the next
3114                     command forward in time is accessed.
3115 
3116                     Equivalent to j.
3117 
3118 
3119        [count][B
3120                     Fetch the next command. Each time j is entered, the next
3121                     command forward in time is accessed.
3122 
3123                     Equivalent to j.
3124 
3125 
3126        [count]G
3127                     Fetch command number count. The default is the least
3128                     recent history command.
3129 
3130 
3131        /string
3132                     Search backward through history for a previous command
3133                     containing string.  string is terminated by a RETURN or
3134                     NEWLINE. If string is preceded by a ^, the matched line
3135                     must begin with string. If string is null, the previous
3136                     string is used.
3137 
3138 
3139        ?string
3140                     Search forward through history for a previous command
3141                     containing string.  string is terminated by a RETURN or
3142                     NEWLINE. If string is preceded by a ^, the matched line
3143                     must begin with string. If string is null, the previous
3144                     string is used.
3145 
3146                     Same as / except that search is in the forward direction.
3147 
3148 
3149        n
3150                     Search in the backwards direction for the next match of
3151                     the last pattern to / or ? commands.
3152 
3153 
3154        N
3155                     Search in the forward direction for next match of the last
3156                     pattern to / or ?.
3157 
3158 
3159    Text Modification Edit Commands
3160        The following commands modify the line:
3161 
3162        a
3163                           Enter input mode and enter text after the current
3164                           character.
3165 
3166 
3167        A
3168                           Append text to the end of the line. Equivalent to
3169                           $a.
3170 
3171 
3172        [count]cmotion
3173        c[count]motion
3174                           Delete current character through the character that
3175                           motion would move the cursor to and enter input
3176                           mode. If motion is c, the entire line is deleted and
3177                           input mode entered.
3178 
3179 
3180        C
3181                           Delete the current character through the end of line
3182                           and enter input mode.  Equivalent to c$.
3183 
3184 
3185        S
3186                           Equivalent to cc.
3187 
3188 
3189        [count]s
3190                           Replace characters under the cursor in input mode.
3191 
3192 
3193        D[count]dmotion
3194                           Delete the current character through the end of
3195                           line. Equivalent to d$.
3196 
3197 
3198        d[count]motion
3199                           Delete current character through the character that
3200                           motion would move to.  If motion is d , the entire
3201                           line is deleted.
3202 
3203 
3204        i
3205                           Enter input mode and insert text before the current
3206                           character.
3207 
3208 
3209        I
3210                           Insert text before the beginning of the line.
3211                           Equivalent to 0i.
3212 
3213 
3214        [count]P
3215                           Place the previous text modification before the
3216                           cursor.
3217 
3218 
3219        [count]p
3220                           Place the previous text modification after the
3221                           cursor.
3222 
3223 
3224        R
3225                           Enter input mode and replace characters on the
3226                           screen with characters you type overlay fashion.
3227 
3228 
3229        [count]rc
3230                           Replace the count characters starting at the current
3231                           cursor position with c, and advance the cursor.
3232 
3233 
3234        [count]x
3235                           Delete current character.
3236 
3237 
3238        [count]X
3239                           Delete preceding character.
3240 
3241 
3242        [count].
3243                           Repeat the previous text modification command.
3244 
3245 
3246        [count]~
3247                           Invert the case of the count characters starting at
3248                           the current cursor position and advance the cursor.
3249 
3250 
3251        [count]_
3252                           Causes the count word of the previous command to be
3253                           appended and input mode entered. The last word is
3254                           used if count is omitted.
3255 
3256 
3257        *
3258                           Causes an * to be appended to the current word and
3259                           file name generation attempted. If no match is
3260                           found, it rings the bell. Otherwise, the word is
3261                           replaced by the matching pattern and input mode is
3262                           entered.
3263 
3264 
3265        \
3266                           Command or file name completion as described in this
3267                           manual page.
3268 
3269 
3270    Other Edit Commands
3271        The following miscellaneous edit commands are supported:
3272 
3273        [count]ymotion
3274        y[count]motion
3275                          Yank the current character through the character to
3276                          which motion would move the cursor. Put the yanked
3277                          characters in the delete buffer. The text and cursor
3278                          position are unchanged.
3279 
3280 
3281        yy
3282                          Yank the current line.
3283 
3284 
3285        Y
3286                          Yank the current line from the current cursor
3287                          location to the end of the line.  Equivalent to y$.
3288 
3289 
3290        u
3291                          Undo the last text modifying command.
3292 
3293 
3294        U
3295                          Undo all the text modifying commands performed on
3296                          current line.
3297 
3298 
3299        [count]V
3300                          Return the command :
3301 
3302                            hist -e ${VISUAL:-${EDITOR:-vi}} count
3303 
3304 
3305                          in the input buffer. If count is omitted, the current
3306                          line is used.
3307 
3308 
3309        ^L
3310                          Line feed and print the current line. This command
3311                          only works in control mode.
3312 
3313 
3314        ^J
3315                          New line. Execute the current line, regardless of
3316                          mode.
3317 
3318 
3319        ^M
3320                          Return. Execute the current line, regardless of mode.
3321 
3322 
3323        #
3324                          If the first character of the command is a # , delete
3325                          this # and each # that follows a NEWLINE.
3326 
3327                          Otherwise, send the line after inserting a # in front
3328                          of each line in the command.
3329 
3330                          This is command is useful for causing the current
3331                          line to be inserted in the history as a comment and
3332                          un-commenting previously commented commands in the
3333                          history file.
3334 
3335 
3336        [count]=
3337                          If count is not specified, generate the list of
3338                          matching commands or file names as described in this
3339                          manual page.
3340 
3341                          Otherwise, replace the word at the current cursor
3342                          location with the count item from the most recently
3343                          generated command or file list. If the cursor is not
3344                          on a word, it is inserted after the current cursor
3345                          location.
3346 
3347 
3348        @letter
3349                          Search your alias list for an alias by the name
3350                          letter. If an alias of this name is defined, insert
3351                          its value on the input queue for processing.
3352 
3353 
3354        ^V
3355                          Display version of the shell.
3356 
3357 
3358    Built-in Commands
3359        The following simple-commands are executed in the shell process. Input
3360        and output redirection is permitted. Unless otherwise indicated, the
3361        output is written on file descriptor 1 and the exit status, when there
3362        is no syntax error, is 0. Except for :, true, false, echo, newgrp, and
3363        login, all built-in commands accept -- to indicate the end of options.
3364        They also interpret the option --man as a request to display the manual
3365        page onto standard error and -? as a help request which prints a usage
3366        message on standard error.
3367 
3368 
3369        Commands that are preceded by one or two ++ symbols are special built-
3370        in commands and are treated specially in the following ways:
3371 
3372            1.     Variable assignment lists preceding the command remain in
3373                   effect when the command completes.
3374 
3375            2.     I/O redirections are processed after variable assignments.
3376 
3377            3.     Errors cause a script that contains them to abort.
3378 
3379            4.     They are not valid function names.
3380 
3381            5.     Words following a command preceded by ++ that are in the
3382                   format of a variable assignment are expanded with the same
3383                   rules as a variable assignment.  This means that tilde
3384                   substitution is performed after the = sign and field
3385                   splitting and file name generation are not performed.
3386 
3387        + : [arg ...]
3388 
3389            The command only expands parameters.
3390 
3391 
3392        + . name [arg ...]
3393 
3394            If name is a function defined with the function name reserved word
3395            syntax, the function is executed in the current environment (as if
3396            it had been defined with the name() syntax.) Otherwise if name
3397            refers to a file, the file is read in its entirety and the commands
3398            are executed in the current shell environment. The search path
3399            specified by PATH is used to find the directory containing the
3400            file. If any arguments arg are specified, they become the
3401            positional parameters while processing the . command and the
3402            original positional parameters are restored upon completion.
3403            Otherwise the positional parameters are unchanged. The exit status
3404            is the exit status of the last command executed.
3405 
3406 
3407        ++ alias [-ptx] [name[ =value]] ...
3408 
3409            alias with no arguments prints the list of aliases in the form
3410            name=value on standard output. The -p option causes the word alias
3411            to be inserted before each one. When one or more arguments are
3412            specified, an alias is defined for each name whose value is
3413            specified. A trailing space in value causes the next word to be
3414            checked for alias substitution. The obsolete -t option is used to
3415            set and list tracked aliases. The value of a tracked alias is the
3416            full pathname corresponding to the specified name. The value
3417            becomes undefined when the value of PATH is reset but the alias
3418            remains tracked. Without the -t option, for each name in the
3419            argument list for which no value is specified, the name and value
3420            of the alias is printed. The obsolete -x option has no effect. The
3421            exit status is non-zero if a name is specified, but no value, and
3422            no alias has been defined for the name.
3423 
3424 
3425        bg [ job...]
3426 
3427            This command is only on systems that support job control. Puts each
3428            specified job into the background. The current job is put in the
3429            background if job is not specified. See the Jobs section of this
3430            manual page for a description of the format of job.
3431 
3432 
3433        + break [n]
3434 
3435            Exit from the enclosing for, while, until, or select loop, if any.
3436            If n is specified, then break n levels.
3437 
3438 
3439        builtin [-ds ] [-f file] [name ...]
3440 
3441            If name is not specified, and no -f option is specified, the built-
3442            ins are printed on standard output. The -s option prints only the
3443            special built-ins. Otherwise, each name represents the pathname
3444            whose basename is the name of the built-in. The entry point
3445            function name is determined by prepending b_ to the built-in name.
3446            A built-in specified by a pathname will only be executed when that
3447            pathname would be found during the path search. Built-ins found in
3448            libraries loaded via the .paths file will be associate with the
3449            pathname of the directory containing the .paths file.
3450 
3451            The ISO C/C++ prototype is bmycommand(int argc, char *argv[], void
3452            *context) for the built-in command mycommand where argv is an array
3453            of argc elements and context is an optional pointer to a Shell_t
3454            structure as described in <ast/shell.h> Special built-ins cannot be
3455            bound to a pathname or deleted. The -d option deletes each of the
3456            specified built-ins. On systems that support dynamic loading, the
3457            -f option names a shared library containing the code for built-ins.
3458            The shared library prefix and/or suffix, which depend on the
3459            system, can be omitted. Once a library is loaded, its symbols
3460            become available for subsequent invocations of builtin. Multiple
3461            libraries can be specified with separate invocations of the builtin
3462            command. Libraries are searched in the reverse order in which they
3463            are specified. When a library is loaded, it looks for a function in
3464            the library whose name is lib_init() and invokes this function with
3465            an argument of 0.
3466 
3467 
3468        cd [-LP] [arg]
3469        cd [-LP] old new
3470 
3471            This command has two forms.
3472 
3473            In the first form it changes the current directory to arg. If arg
3474            is a -, the directory is changed to the previous directory. The
3475            shell variable HOME is the default arg. The variable PWD is set to
3476            the current directory. The shell variable CDPATH defines the search
3477            path for the directory containing arg. Alternative directory names
3478            are separated by a colon (:). The default path is NULL (specifying
3479            the current directory). The current directory is specified by a
3480            null path name, which can appear immediately after the equal sign
3481            or between the colon delimiters anywhere else in the path list. If
3482            arg begins with a /, the search path is not used. Otherwise, each
3483            directory in the path is searched for arg.
3484 
3485            The second form of cd substitutes the string new for the string old
3486            in the current directory name, PWD, and tries to change to this new
3487            directory. By default, symbolic link names are treated literally
3488            when finding the directory name. This is equivalent to the -L
3489            option. The -P option causes symbolic links to be resolved when
3490            determining the directory. The last instance of -L or -P on the
3491            command line determines which method is used. The cd command cannot
3492            be executed by rksh93.
3493 
3494 
3495        command [-pvVx] name [arg ...]
3496 
3497            Without the -v or -V options, executes name with the arguments
3498            specified by arg.
3499 
3500            The -p option causes a default path to be searched rather than the
3501            one defined by the value of PATH. Functions are not searched when
3502            finding name. In addition, if name refers to a special built-in,
3503            none of the special properties associated with the leading daggers
3504            are honored. For example, the predefined alias redirect='command
3505            exec' prevents a script from terminating when an invalid
3506            redirection is specified.
3507 
3508            With the -x option, if command execution would result in a failure
3509            because there are too many arguments, errno E2BIG, the shell
3510            invokes command name multiple times with a subset of the arguments
3511            on each invocation. Arguments that occur prior to the first word
3512            that expands to multiple arguments and after the last word that
3513            expands to multiple arguments are passed on each invocation. The
3514            exit status is the maximum invocation exit status.
3515 
3516            With the -v option, command is equivalent to the built-in whence
3517            command described in this section. The -V option causes command to
3518            act like whence -v.
3519 
3520 
3521        +continue [n]
3522 
3523            Resumes the next iteration of the enclosing for, while, until, or
3524            select loop. If n is specified, then resume at the nth enclosing
3525            loop.
3526 
3527 
3528        disown [job...]
3529 
3530            Causes the shell not to send a HUP signal to each specified job, or
3531            all active jobs if job is omitted, when a login shell terminates.
3532 
3533 
3534        echo [arg ...]
3535 
3536            When the first arg does not begin with a -, and none of the
3537            arguments contain a backslash (\), prints each of its arguments
3538            separated by a SPACE and terminated by a NEWLINE. Otherwise, the
3539            behavior of echo is system dependent and print or printf described
3540            in this section should be used. See echo(1) for usage and
3541            description.
3542 
3543 
3544        ++enum [ -i ] type[=(value ...) ]
3545 
3546            Creates a declaration command named type that is an integer type
3547            that allows one of the specified values as enumeration names. If
3548            =(value ...) is omitted, then type must be an indexed array
3549            variable with at least two elements and the values are taken from
3550            this array variable.  If -i is specified the values are case
3551            insensitive.
3552 
3553 
3554        +eval [arg ...]
3555 
3556            The arguments are read as input to the shell and the resulting
3557            commands are executed.
3558 
3559 
3560        +exec [-c] [-a name ...] [arg ...]
3561 
3562            If arg is specified, the command specified by the arguments is
3563            executed in place of this shell without creating a new process. The
3564            -c option causes the environment to be cleared before applying
3565            variable assignments associated with the exec invocation. The -a
3566            option causes name rather than the first arg, to become argv[0] for
3567            the new process.  Input and output arguments can appear and affect
3568            the current process. If arg is not specified, the effect of this
3569            command is to modify file descriptors as prescribed by the
3570            input/output redirection list. In this case, any file descriptor
3571            numbers greater than 2 that are opened with this mechanism are
3572            closed when invoking another program.
3573 
3574 
3575        +exit [n]
3576 
3577            Causes the shell to exit with the exit status specified by n. The
3578            value is the least significant 8 bits of the specified status. If n
3579            is omitted, then the exit status is that of the last command
3580            executed. An end-of-file also causes the shell to exit except for a
3581            shell which has the ignoreeof option turned on. See set.
3582 
3583 
3584        ++export [-p] [name[=value]] ...
3585 
3586            If name is not specified, the names and values of each variable
3587            with the export attribute are printed with the values quoted in a
3588            manner that allows them to be re-entered. The export command is the
3589            same as typeset -x except that if you use export within a function,
3590            no local variable is created. The -p option causes the word export
3591            to be inserted before each one. Otherwise, the specified names are
3592            marked for automatic export to the environment of subsequently-
3593            executed commands.
3594 
3595 
3596        false
3597 
3598            Does nothing, and exits 1. Used with until for infinite loops.
3599 
3600 
3601        fg [job ...]
3602 
3603            This command is only on systems that support job control. Each job
3604            specified is brought to the foreground and waited for in the
3605            specified order.  Otherwise, the current job is brought into the
3606            foreground. See Jobs for a description of the format of job.
3607 
3608 
3609        getconf [name [pathname]]
3610 
3611            Prints the current value of the configuration parameter specified
3612            by name. The configuration parameters are defined by the IEEE POSIX
3613            1003.1 and IEEE POSIX 1003.2 standards. See pathconf(2) and
3614            sysconf(3C).
3615 
3616            The pathname argument is required for parameters whose value
3617            depends on the location in the file system. If no arguments are
3618            specified, getconf prints the names and values of the current
3619            configuration parameters. The pathname / is used for each of the
3620            parameters that requires pathname.
3621 
3622 
3623        getopts [ -a name] optstring vname [arg ...]
3624 
3625            Checks arg for legal options. If arg is omitted, the positional
3626            parameters are used. An option argument begins with a + or a -. An
3627            option that does not begin with + or - or the argument -- ends the
3628            options. Options beginning with + are only recognized when
3629            optstring begins with a +. optstring contains the letters that
3630            getopts recognizes. If a letter is followed by a :, that option is
3631            expected to have an argument. The options can be separated from the
3632            argument by blanks. The option -?causes getopts to generate a usage
3633            message on standard error. The -a option can be used to specify the
3634            name to use for the usage message, which defaults to $0. getopts
3635            places the next option letter it finds inside variable vname each
3636            time it is invoked. The option letter is prepended with a + when
3637            arg begins with a +. The index of the next arg is stored in OPTIND.
3638            The option argument, if any, gets stored in OPTARG. A leading : in
3639            optstring causes getopts to store the letter of an invalid option
3640            in OPTARG, and to set vname to ? for an unknown option and to: when
3641            a required option argument is missing. Otherwise, getopts prints an
3642            error message. The exit status is non-zero when there are no more
3643            options. There is no way to specify any of the options :, +, -, ?,
3644            [, and ]. The option # can only be specified as the first option.
3645 
3646 
3647        hist [ -e ename][-nlr] [ first[last ] ]
3648        hist -s [ old=new ] [ command]
3649 
3650            In the first form, a range of commands from first to last is
3651            selected from the last HISTSIZE commands that were typed at the
3652            terminal.  The arguments first and last can be specified as a
3653            number or as a string. A string is used to locate the most recent
3654            command starting with the specified string. A negative number is
3655            used as an offset to the current command number. If the -l option
3656            is selected, the commands are listed on standard output. Otherwise,
3657            the editor program ename is invoked on a file containing these
3658            keyboard commands. If ename is not supplied, then the value of the
3659            variable HISTEDIT is used. If HISTEDIT is not set, then FCEDIT
3660            (default /bin/ed) is used as the editor. When editing is complete,
3661            the edited command(s) is executed if the changes have been saved.
3662            If last is not specified, then it is set to first. If first is not
3663            specified, the default is the previous command for editing and -16
3664            for listing. The option -r reverses the order of the commands and
3665            the option -n suppresses command numbers when listing. In the
3666            second form, command is interpreted as first described in this
3667            section and defaults to the last command executed. The resulting
3668            command is executed after the optional substitution old=new is
3669            performed.
3670 
3671 
3672        jobs -lnp [job ...]
3673 
3674            Lists information about each specified job, or all active jobs if
3675            job is omitted. The -l option lists process ids in addition to the
3676            normal information. The -n option only displays jobs that have
3677            stopped or exited since last notified. The -p option causes only
3678            the process group to be listed. See Jobs for a description of the
3679            format of job.
3680 
3681 
3682        kill [-s signame] job ...
3683        kill [-n signum] job ...
3684        kill -Ll [sig ...]
3685 
3686            Sends either the TERM (terminate) signal or the specified signal to
3687            the specified jobs or processes. Signals are either specified by
3688            number with the -n option or by name with the -s option (as
3689            specified in <signal.h>, stripped of   the prefix `SIG with the
3690            exception that SIGCLD is named CHLD). For backward compatibility,
3691            the n and s can be omitted and the number or name placed
3692            immediately after the -. If the signal being sent is TERM
3693            (terminate) or HUP (hang up), then the job or process is sent a
3694            CONT (continue) signal if it is stopped. The argument job can be
3695            the process id of a process that is not a member of one of the
3696            active jobs. See Jobs for a description of the format of job. In
3697            the third form, kill -l or kill -L, if sig is not specified, the
3698            signal names are listed. The -l option lists only the signal names
3699            whereas -L lists each signal name and corresponding number.
3700            Otherwise, for each sig that is a name, the corresponding signal
3701            number is listed. For each sig that is a number, the signal name
3702            corresponding to the least significant 8 bits of sig is listed.
3703 
3704 
3705        let [arg ...]
3706 
3707            Each arg is a separate arithmetic expression to be evaluated.  let
3708            only recognizes octal constants starting with 0 when the set option
3709            letoctal is on. See the Arithmetic Evaluation section of this
3710            manual page for a description of arithmetic expression evaluation.
3711            The exit status is 0 if the value of the last expression is non-
3712            zero, and 1 otherwise.
3713 
3714 
3715        +newgrp [arg ...]
3716 
3717            Equivalent to exec /bin/newgrp arg ...
3718 
3719 
3720        print [-CRenprsv] [ -u unit] [ -f format ] [ arg ...]
3721 
3722            With no options or with option - or --, each arg is printed on
3723            standard output. The -f option causes the arguments to be printed
3724            as described by printf. In this case, any e, n, r, or R options are
3725            ignored. Otherwise, unless the -R or -r, are specified, the
3726            following escape conventions are applied:
3727 
3728            \a
3729                    Alert character (ASCII 07)
3730 
3731 
3732            \b
3733                    Backspace character (ASCII 010)
3734 
3735 
3736            \c
3737                    Causes print to end without processing more arguments and
3738                    not adding a NEWLINE
3739 
3740 
3741            \f
3742                    Form-feed character (ASCII 014)
3743 
3744 
3745            \n
3746                    NEWLINE character (ASCII 012)
3747 
3748 
3749            \r
3750                    RETURN character (ASCII 015)
3751 
3752 
3753            \t
3754                    TAB character (ASCII 011)
3755 
3756 
3757            \v
3758                    Vertical TAB character (ASCII 013)
3759 
3760 
3761            \E
3762                    Escape character (ASCII 033)
3763 
3764 
3765            \\
3766                    Backslash character \
3767 
3768 
3769            \0x
3770                    Character defined by the 1, 2, or 3-digit octal string
3771                    specified by x
3772 
3773            The -R option prints all subsequent arguments and options other
3774            than -n. The -e causes the escape conventions to be applied This is
3775            the default behavior. It reverses the effect of an earlier -r. The
3776            -p option causes the arguments to be written onto the pipe of the
3777            process spawned with |& instead of standard output. The -v option
3778            treats each arg as a variable name and writes the value in the
3779            printf %B format. The -C option treats each arg as a variable name
3780            and writes the values in the printf %#B format.  The -s option
3781            causes the arguments to be written onto the history file instead of
3782            standard output. The -u option can be used to specify a one digit
3783            file descriptor unit number unit on which the output is placed. The
3784            default is 1. If the option -n is used, no NEWLINE is added to the
3785            output.
3786 
3787 
3788        printf format [arg ...]
3789 
3790            The arguments arg are printed on standard output in accordance with
3791            the ANSI-C formatting rules associated with the format string
3792            format.  If the number of arguments exceeds the number of format
3793            specifications, the format string is reused to format remaining
3794            arguments. The following extensions can also be used:
3795 
3796 
3797            %b
3798 
3799                A %b format can be used instead of %s to cause escape sequences
3800                in the corresponding arg to be expanded as described in print.
3801 
3802 
3803            %B
3804 
3805                A %B option causes each of the arguments to be treated as
3806                variable names and the binary value of the variables is
3807                printed. This is most useful for variables with an attribute of
3808                b.
3809 
3810 
3811            %H
3812 
3813                A %H format can be used instead of %s to cause characters in
3814                arg that are special in HTML and XML to be output as their
3815                entity name. The alternate flag # formats the output for use as
3816                a URI.
3817 
3818 
3819            %P
3820 
3821                A %P format can be used instead of %s to cause arg to be
3822                interpreted as an extended regular expression and be printed as
3823                a shell pattern.
3824 
3825 
3826 
3827            %R
3828 
3829                A %R format can be used instead of %s to cause arg to be
3830                interpreted as a shell pattern and to be printed as an extended
3831                regular expression.
3832 
3833 
3834            %q
3835 
3836                A %q format can be used instead of %s to cause the resulting
3837                string to be quoted in a manner than can be input again to the
3838                shell. When q is preceded by the alternative format specifier,
3839                #, the string is quoted in manner suitable as a field in a .csv
3840                format file.
3841 
3842 
3843            %(date-format)
3844 
3845                A %(date-format)T format can be use to treat an argument as a
3846                date/time string and to format the date/time according to the
3847                date-format as defined for the date(1) command.
3848 
3849 
3850 
3851            %Z
3852 
3853                A %Z format outputs a byte whose value is 0.
3854 
3855 
3856            %d
3857 
3858                The precision field of the %d format can be followed by a . and
3859                the output base. In this case, the # flag character causes
3860                base# to be prepended.
3861 
3862 
3863            #
3864 
3865                The # flag, when used with the %d format without an output
3866                base, displays the output in powers of 1000 indicated by one of
3867                the following suffixes: k M G T P E, and when used with the %i
3868                format displays the output in powers of 1024 indicated by one
3869                of the following suffixes: Ki Mi Gi Ti Pi Ei.
3870 
3871 
3872 
3873            =
3874 
3875                The = flag centers the output within the specified field width.
3876 
3877 
3878            L
3879 
3880                The L flag, when used with the %c or %s formats, treats
3881                precision as character width instead of byte count.
3882 
3883 
3884            ,
3885 
3886                The , flag, when used with the %d or %f formats, separates
3887                groups of digits with the grouping delimiter (, in groups of 3
3888                in the C locale).
3889 
3890 
3891 
3892 
3893        pwd [-LP]
3894 
3895            Outputs the value of the current working directory. The -L option
3896            is the default. It prints the logical name of the current
3897            directory. If the -P option is specified, all symbolic links are
3898            resolved from the name. The last instance of -L or -P on the
3899            command line determines which method is used.
3900 
3901 
3902        read [-ACSprsv] [-d delim] [ -n n] [[ -N n] [[-t timeout] [-u unit]
3903        [vname?prompt] [ vname ... ]
3904 
3905            The shell input mechanism. One line is read and is broken up into
3906            fields using the characters in IFS as separators. The escape
3907            character, \, is used to remove any special meaning for the next
3908            character and for line continuation.  The -d option causes the read
3909            to continue to the first character of delim rather than NEWLINE.
3910            The -n option causes at most n bytes to read rather a full line but
3911            returns when reading from a slow device as soon as any characters
3912            have been read. The -N option causes exactly n to be read unless an
3913            end-of-file has been encountered or the read times out because of
3914            the -t option. In raw mode, -r, the \ character is not treated
3915            specially. The first field is assigned to the first vname, the
3916            second field to the second vname, etc., with leftover fields
3917            assigned to the last vname. When vname has the binary attribute and
3918            -n or -N is specified, the bytes that are read are stored directly
3919            into the variable. If the -v is specified, then the value of the
3920            first vname is used as a default value when reading from a terminal
3921            device. The -A option causes the variable vname to be unset and
3922            each field that is read to be stored in successive elements of the
3923            indexed array vname. The -C option causes the variable vname to be
3924            read as a compound variable. Blanks will be ignored when finding
3925            the beginning open parenthesis. The -S option causes the line to be
3926            treated like a record in a .csv format file so that double quotes
3927            can be used to allow the delimiter character and the new-line
3928            character to appear within a field.  The -p option causes the input
3929            line to be taken from the input pipe of a process spawned by the
3930            shell using |&. If the -s option is present,     the input is saved as
3931            a command in the history file. The option -u can be used to specify
3932            a one digit file descriptor unit unit to read from. The file
3933            descriptor can be opened with the exec special built-in command.
3934            The default value of unit n is 0. The option -t is used to specify
3935            a time out in seconds when reading from a terminal or pipe. If
3936            vname is omitted, then REPLY is used as the default vname. An end-
3937            of-file with the -p option causes cleanup for this process so that
3938            another can be spawned. If the first argument contains a ?, the
3939            remainder of this word is used as a prompt on standard error when
3940            the shell is interactive. The exit status is 0 unless an end-of-
3941            file is encountered or read has timed out.
3942 
3943 
3944        ++readonly [-p] [ vname[=value]] ...
3945 
3946            If vname is not specified, the names and values of each variable
3947            with the read-only attribute is printed with the values quoted in a
3948            manner that allows them to be input again. The -p option causes the
3949            word readonly to be inserted before each one. Otherwise, the
3950            specified vnames are marked readonly and these names cannot be
3951            changed by subsequent assignment.
3952 
3953 
3954        +return [n]
3955 
3956            Causes a shell function or script to return to the invoking script
3957            with the exit status specified by n. The value is the least
3958            significant 8 bits of the specified status. If n is omitted, then
3959            the return status is that of the last command executed. If return
3960            is invoked while not in a function or a script, then it behaves the
3961            same as exit.
3962 
3963 
3964        +set [ +-BCGabefhkmnoprstuvx] [+-o [ option ] ] ... [ +-A vname]
3965        [arg...]
3966 
3967            The set command supports the following options:
3968 
3969            -a
3970 
3971                All subsequent variables that are defined are automatically
3972                exported.
3973 
3974 
3975            -A
3976 
3977                Array assignment. Unset the variable vname and assign values
3978                sequentially from the arg list. If +A is used, the variable
3979                vname is not unset first.
3980 
3981 
3982            -b
3983 
3984                Prints job completion messages as soon as a background job
3985                changes state rather than waiting for the next prompt.
3986 
3987 
3988            -B
3989 
3990                Enable brace pattern field generation. This is the default
3991                behavior.
3992 
3993 
3994            -C
3995 
3996                Prevents redirection (>)      from truncating existing files. Files
3997                that are created are opened with the O_EXCL mode. Requires >|
3998                to truncate a file when turned on.
3999 
4000 
4001            -e
4002 
4003                Unless contained in a || or && command, or the command
4004                following an if, while or until command or in the pipeline
4005                following !, if a command has a non-zero exit status, execute
4006                the ERR trap, if set, and exit. This mode is disabled while
4007                reading profiles.
4008 
4009 
4010            -f
4011 
4012                Disables file name generation.
4013 
4014 
4015            -G
4016 
4017                Causes the pattern ** by itself to match files and zero or more
4018                directories and subdirectories when used for file name
4019                generation. If followed by a / only directories and
4020                subdirectories are matched.
4021 
4022 
4023            -h
4024 
4025                Each command becomes a tracked alias when first encountered.
4026 
4027 
4028            -k
4029 
4030                Obsolete. All variable assignment arguments are placed in the
4031                environment for a command, not just those that precede the
4032                command name.
4033 
4034 
4035            -m
4036 
4037                Background jobs run in a separate process group and a line
4038                prints upon completion. The exit status of background jobs is
4039                reported in a completion message. On systems with job control,
4040                this option is turned on automatically for interactive shells.
4041 
4042 
4043            -n
4044 
4045                Read commands and check them for syntax errors, but do not
4046                execute them.  Ignored for interactive shells.
4047 
4048 
4049            -o
4050 
4051                If no option name is supplied, the list of options and their
4052                current settings are written to standard output. When invoked
4053                with a +, the options are written in a format that can be input
4054                again to the shell to restore the settings. This option can be
4055                repeated to enable or disable multiple options.
4056 
4057                The following argument can be one of the following option
4058                names:
4059 
4060                allexport
4061 
4062                    Same as -a.
4063 
4064 
4065                bgnice
4066 
4067                    All background jobs are run at a lower priority. This is
4068                    the default mode.
4069 
4070 
4071                braceexpand
4072 
4073                    Same as -B.
4074 
4075 
4076                emacs
4077 
4078                    Puts you in an emacs style inline editor for command entry.
4079 
4080 
4081                errexit
4082 
4083                    Same as -e.
4084 
4085 
4086                globstar
4087 
4088                    Same as -G.
4089 
4090 
4091                gmacs
4092 
4093                    Puts you in a gmacs style inline editor for command entry.
4094 
4095 
4096                ignoreeof
4097 
4098                    The shell does not exit on end-of-file. The command exit
4099                    must be used.
4100 
4101 
4102                keyword
4103 
4104                    Same as -k.
4105 
4106 
4107                letoctal
4108 
4109                    The let command allows octal constants starting with 0.
4110 
4111 
4112                markdirs
4113 
4114                    All directory names resulting from file name generation
4115                    have a trailing / appended.
4116 
4117 
4118                monitor
4119 
4120                    Same as -m.
4121 
4122 
4123                multiline
4124 
4125                    The built-in editors use multiple lines on the screen for
4126                    lines that are longer than the width of the screen. This
4127                    might not work for all terminals.
4128 
4129 
4130                noclobber
4131 
4132                    Same as -C.
4133 
4134 
4135                noexec
4136 
4137                    Same as -n.
4138 
4139 
4140                noglob
4141 
4142                    Same as -f.
4143 
4144 
4145                nolog
4146 
4147                    Do not save function definitions in the history file.
4148 
4149 
4150                notify
4151 
4152                    Same as -b.
4153 
4154 
4155                nounset
4156 
4157                    Same as -u.
4158 
4159 
4160                pipefail
4161 
4162                    A pipeline does not complete until all components of the
4163                    pipeline have completed, and the return value is the value
4164                    of the last non-zero command to fail or zero if no command
4165                    has failed.
4166 
4167 
4168                privileged
4169 
4170                    Same as -p.
4171 
4172 
4173                showme
4174 
4175                    When enabled, simple commands or pipelines preceded by a a
4176                    semicolon (;) is displayed as if the xtrace option were
4177                    enabled but is not executed.  Otherwise, the leading ; is
4178                    ignored.
4179 
4180 
4181                trackall
4182 
4183                    Same as -h.
4184 
4185 
4186                verbose
4187 
4188                    Same as -v.
4189 
4190 
4191                vi
4192 
4193                    Puts you in insert mode of a vi style inline editor until
4194                    you hit the escape character 033. This puts you in control
4195                    mode. A return sends the line.
4196 
4197 
4198                viraw
4199 
4200                    Each character is processed as it is typed in vi mode.
4201 
4202 
4203                xtrace
4204 
4205                    Same as -x.
4206 
4207                    If no option name is supplied, the current options settings
4208                    are printed.
4209 
4210 
4211 
4212            -p
4213 
4214                Disables processing of the $HOME/.profile file and uses the
4215                file /etc/suid_profile instead of the ENV file. This mode is on
4216                whenever the effective uid (gid) is not equal to the real uid
4217                (gid). Turning this off causes the effective uid and gid to be
4218                set to the real uid and gid.
4219 
4220 
4221            -r
4222 
4223                Enables the restricted shell. This option cannot be unset once
4224                set.
4225 
4226 
4227            -s
4228 
4229                Sort the positional parameters lexicographically.
4230 
4231 
4232            -t
4233 
4234                Obsolete. Exit after reading and executing one command.
4235 
4236 
4237            -u
4238 
4239                Treat unset parameters as an error when substituting.
4240 
4241 
4242            -v
4243 
4244                Print shell input lines as they are read.
4245 
4246 
4247            -x
4248 
4249                Print commands and their arguments as they are executed.
4250 
4251 
4252            --
4253 
4254                Do not change any of the options. This is useful in setting $1
4255                to a value beginning with -. If no arguments follow this option
4256                then the positional parameters are unset.
4257 
4258            As an obsolete feature, if the first arg is - then the -x and -v
4259            options are turned off and the next arg is treated as the first
4260            argument. Using + rather than - causes these options to be turned
4261            off. These options can also be used upon invocation of the shell.
4262            The current set of options can be found in $-. Unless -A is
4263            specified, the remaining arguments are positional parameters and
4264            are assigned, in order, to $1 $2 .... If no arguments are
4265            specified, then the names and values of all variables are printed
4266            on the standard output.
4267 
4268 
4269        +shift [n]
4270 
4271            The positional parameters from $n+1 ... are renamed $1 ..., the
4272            default n is 1. The parameter n can be any arithmetic expression
4273            that evaluates to a non-negative number less than or equal to $#.
4274 
4275 
4276        sleep seconds
4277 
4278            Suspends execution for the number of decimal seconds or fractions
4279            of a second specified by seconds.
4280 
4281 
4282        +trap -p [action] [sig] ...
4283 
4284            The -p option causes the trap action associated with each trap as
4285            specified by the arguments to be printed with appropriate quoting.
4286            Otherwise, action is processed as if it were an argument to eval
4287            when the shell receives signal(s) sig. Each sig can be specified as
4288            a number or as the name of the signal. Trap commands are executed
4289            in order of signal number. Any attempt to set a trap on a signal
4290            that was ignored on entry to the current shell is ineffective. If
4291            action is omitted and the first sig is a number, or if action is -,
4292            then the trap(s) for each sig are reset to their original values.
4293            If action is the null string then this signal is ignored by the
4294            shell and by the commands it invokes.  If sig is ERR then action is
4295            executed whenever a command has a non-zero exit status. If sig is
4296            DEBUG then action is executed before each command. The variable
4297            .sh.command contains the contents of the current command line when
4298            action is running. If sig is 0 or EXIT and the trap statement is
4299            executed inside the body of a function defined with the function
4300            name syntax, then the command action is executed after the function
4301            completes. If sig is 0 or EXIT for a trap set outside any function
4302            then the command action is executed on exit from the shell. If sig
4303            is KEYBD, then action is executed whenever a key is read while in
4304            emacs, gmacs, or vi mode. The trap command with no arguments prints
4305            a list of commands associated with each signal number.
4306 
4307 
4308        true
4309 
4310            Does nothing, and exits 0. Used with while for infinite loops.
4311 
4312 
4313        ++typeset [+-ACHSfblmnprtux ] [ +-EFLRXZi[n] ] [ +-M [ mapname ] ] [ -T
4314        [ tname=(assign_list) ] ] [ -h str ] [ -a [type] ] [ vname[=value ] ]
4315 
4316            Sets attributes and values for shell variables and functions. When
4317            invoked inside a function defined with the function name syntax, a
4318            new instance of the variable vname is created, and the variable's
4319            value and type are restored when the function completes.
4320 
4321            Using + rather than - causes these options to be turned off. If no
4322            vname arguments are specified, a list of vnames (and optionally the
4323            values) of the variables is printed. Using + rather than - keeps
4324            the values from being printed.) The -p option causes typeset
4325            followed by the option letters to be printed before each name
4326            rather than the names of the options. If any option other than -p
4327            is specified, only those variables which have all of the specified
4328            options are printed. Otherwise, the vnames and attributes of all
4329            variables that have attributes are printed.
4330 
4331            The following list of attributes can be specified:
4332 
4333            -a
4334                  Declares vname to be an indexed array. This is optional
4335                  unless except for compound variable assignments.
4336 
4337 
4338            -A
4339                  Declares vname to be an associative array. Sub-scripts are
4340                  strings rather than arithmetic expressions.
4341 
4342 
4343            -b
4344                  The variable can hold any number of bytes of data. The data
4345                  can be text or binary. The value is represented by the base64
4346                  encoding of the data. If -Z is also specified, the size in
4347                  bytes of the data in the buffer is determined by the size
4348                  associated with the -Z. If the base64 string assigned results
4349                  in more data, it is truncated. Otherwise, it is filled with
4350                  bytes whose value is zero. The printf format %B can be used
4351                  to output the actual data in this buffer instead of the
4352                  base64 encoding of the data.
4353 
4354 
4355            -C
4356                  Causes each vname to be a compound variable. If value names a
4357                  compound variable it is copied into vname. Otherwise, it
4358                  unsets each vname.
4359 
4360 
4361            -E
4362                  Declares vname to be a double precision floating point
4363                  number. If n is non-zero, it defines the number of
4364                  significant figures that are used when expanding vname.
4365                  Otherwise, ten significant figures is used.
4366 
4367 
4368            -f
4369                  The names refer to function names rather than variable names.
4370                  No assignments can be made and the only other valid options
4371                  are -t, -u, and -x. The -t option turns on execution tracing
4372                  for this function. The -u option causes this function to be
4373                  marked undefined. The FPATH variable is searched to find the
4374                  function definition when the function is referenced. If no
4375                  options other than -f is specified, then the function
4376                  definition is displayed on standard output. If +f is
4377                  specified, then a line containing the function name followed
4378                  by a shell comment containing the line number and path name
4379                  of the file where this function was defined, if any, is
4380                  displayed.  The names refer to function names rather than
4381                  variable names.  No assignments can be made and the only
4382                  other valid options are -S, -t, -u and -x.  The -S can be
4383                  used with discipline functions defined in a type to indicate
4384                  that the function is static. For a static function, the same
4385                  method will be used by all instances of that type no matter
4386                  which instance references it. In addition, it can only use
4387                  value of variables from the original type definition. These
4388                  discipline functions cannot be redefined in any type
4389                  instance.  The -t option turns on execution tracing for this
4390                  function.  The -u option causes this function to be marked
4391                  undefined.  The FPATH variable will be searched to find the
4392                  function definition when the function is referenced.  If no
4393                  options other than -f is specified, then the function
4394                  definition will be displayed on standard output. If +f is
4395                  specified, then a line containing the function name followed
4396                  by a shell comment containing the line number and path name
4397                  of the file where this function was defined, if any, is
4398                  displayed. The exit status can be used to determine whether
4399                  the function is defined so that typeset -f .sh.math. name
4400                  will return 0 when math function name is defined and non-zero
4401                  otherwise.
4402 
4403                  The -i attribute cannot be specified with -f.
4404 
4405 
4406            -F
4407                  Declares vname to be a double precision floating point
4408                  number. If n is non-zero, it defines the number of places
4409                  after the decimal point that are used when expanding vname.
4410                  Otherwise ten places after the decimal point is used.
4411 
4412 
4413            -h
4414                  Used within type definitions to add information when
4415                  generating information about the sub-variable on the man
4416                  page. It is ignored when used outside of a type definition.
4417                  When used with -f the information is associated with the
4418                  corresponding discipline function.
4419 
4420 
4421            -H
4422                  This option provides UNIX to hostname file mapping on non-
4423                  UNIX machines.
4424 
4425 
4426            -i
4427                  Declares vname to be represented internally as integer. The
4428                  right hand side of an assignment is evaluated as an
4429                  arithmetic expression when assigning to an integer. If n is
4430                  non-zero, it defines the output arithmetic base, otherwise
4431                  the output base is ten.
4432 
4433                  The -i attribute cannot be specified along with -R, -L, -Z,
4434                  or -f.
4435 
4436 
4437            -l
4438                  Used with -i, -E or -F to indicate long integer, or long
4439                  float.  Otherwise, all upper-case characters are converted to
4440                  lower-case.  The upper-case option, -u, is turned off.
4441                  Equivalent to -M tolower.
4442 
4443 
4444            -L
4445                  Left justify and remove leading blanks from value. If n is
4446                  non-zero, it defines the width of the field, otherwise it is
4447                  determined by the width of the value of first assignment.
4448                  When the variable is assigned to, it is filled on the right
4449                  with blanks or truncated, if necessary, to fit into the
4450                  field. The -R option is turned off.
4451 
4452                  The -i attribute cannot be specified with -L.
4453 
4454 
4455            -m
4456                  moves or renames the variable. The value is the name of a
4457                  variable whose value will be moved to vname. The original
4458                  variable will be unset. Cannot be used with any other
4459                  options.
4460 
4461 
4462            -M
4463                  Use the character mapping mapping such as tolower and toupper
4464                  when assigning a value to each of the specified operands.
4465                  When mapping is specified and there are not operands, all
4466                  variables that use this mapping are written to standard
4467                  output.  When mapping is omitted and there are no operands,
4468                  all mapped variables are written to standard output.
4469 
4470 
4471            -n
4472                  Declares vname to be a reference to the variable whose name
4473                  is defined by the value of variable vname. This is usually
4474                  used to reference a variable inside a function whose name has
4475                  been passed as an argument.
4476 
4477 
4478            -p
4479                  The name, attributes and values for the given vname are
4480                  written on standard output in a form that can be used as
4481                  shell input.  If +p is specified, then the values are not
4482                  displayed.
4483 
4484 
4485            -R
4486                  Right justify and fill with leading blanks. If n is non-zero,
4487                  it defines the width of the field, otherwise it is determined
4488                  by the width of the value of first assignment. The field is
4489                  left filled with blanks or truncated from the end if the
4490                  variable is reassigned. The -L option is turned off.
4491 
4492                  The -i attribute cannot be specified with -R.
4493 
4494 
4495            -r
4496                  The specified vnames are marked read-only and these names
4497                  cannot be changed by subsequent assignment.
4498 
4499 
4500            -S
4501                  When used within the assign_list of a type definition, it
4502                  causes the specified sub-variable to be shared by all
4503                  instances of the type. When used inside a function defined
4504                  with the function reserved word, the specified variables will
4505                  have function static scope. Otherwise, the variable is unset
4506                  prior to processing the assignment list.
4507 
4508 
4509            -t
4510                  Tags the variables. Tags are user definable and have no
4511                  special meaning to the shell.
4512 
4513 
4514            -T
4515                  If followed by tname, it creates a type named by tname using
4516                  the compound assignment assign_list to tname. Otherwise, it
4517                  writes all the type definitions to standard output.
4518 
4519 
4520            -u
4521                  When given along with -i specifies unsigned integer.
4522                  Otherwise, all lower-case characters are converted to upper-
4523                  case.  The lower-case option, -l, is turned off.  Equivalent
4524                  to -M toupper.
4525 
4526 
4527            -x
4528                  The specified vnames are marked for automatic export to the
4529                  environment of subsequently-executed commands. Variables
4530                  whose names contain a . cannot be exported.
4531 
4532 
4533            -X
4534                  Declares vname to be a double precision floating point number
4535                  and expands using the %a format of ISO-C99.  If n is non-
4536                  zero, it defines the number of hex digits after the radix
4537                  point that is used when expanding vname.  The default is 10.
4538 
4539 
4540            -Z
4541                  Right justify and fill with leading zeros if the first non-
4542                  blank character is a digit and the -L option has not been
4543                  set. Remove leading zeros if the -L option is also set. If n
4544                  is non-zero, it defines the width of the field, otherwise it
4545                  is determined by the width of the value of first assignment.
4546 
4547                  The -i attribute cannot be specified with -Z.
4548 
4549 
4550 
4551        ulimit [-HSacdfmnpstv] [ limit]
4552 
4553            Set or display a resource limit. Many systems do not support one or
4554            more of these limits. The limit for a specified resource is set
4555            when limit is specified. The value of limit can be a number in the
4556            unit specified with each resource, or the value unlimited. When
4557            more than one resource is specified, then the limit name and unit
4558            is printed before the value.
4559 
4560            If no option is specified, -f is assumed.
4561 
4562            The following are the available resource limits:
4563 
4564            -a
4565                  Lists all of the current resource limits.
4566 
4567 
4568            -c
4569                  The number of 512-byte blocks on the size of core dumps.
4570 
4571 
4572            -d
4573                  The number of Kbytes on the size of the data area.
4574 
4575 
4576            -f
4577                  The number of 512-byte blocks on files that can be written by
4578                  the current process or by child processes (files of any size
4579                  can be read).
4580 
4581 
4582            -H
4583                  Specifies a hard limit for the specified resource.
4584 
4585                  A hard limit cannot be increased once it is set.
4586 
4587                  If neither the -H nor -S option is specified, the limit
4588                  applies to both. The current resource limit is printed when
4589                  limit is omitted. In this case, the soft limit is printed
4590                  unless -H is specified.
4591 
4592 
4593            -m
4594                  The number of Kbytes on the size of physical memory.
4595 
4596 
4597            -n
4598                  The number of file descriptors plus 1.
4599 
4600 
4601            -p
4602                  The number of 512-byte blocks for pipe buffering.
4603 
4604 
4605            -s
4606                  The number of Kbytes on the size of the stack area.
4607 
4608 
4609            -S
4610                  Specifies a soft limit for the specified resource.
4611 
4612                  A soft limit can be increased up to the value of the hard
4613                  limit.
4614 
4615                  If neither the -H nor -S option is specified, the limit
4616                  applies to both. The current resource limit is printed when
4617                  limit is omitted. In this case, the soft limit is printed
4618                  unless -H is specified.
4619 
4620 
4621            -t
4622                  The number of CPU seconds to be used by each process.
4623 
4624 
4625            -v
4626                  The number of Kbytes for virtual memory.
4627 
4628 
4629 
4630        umask [-S][mask]
4631 
4632            The user file-creation mask is set to mask. mask can either be an
4633            octal number or a symbolic value as described in chmod(1).
4634 
4635            If a symbolic value is specified, the new umask value is the
4636            complement of the result of applying mask to the complement of the
4637            previous umask value. If mask is omitted, the current value of the
4638            mask is printed. The -S option causes the mode to be printed as a
4639            symbolic value.  Otherwise, the mask is printed in octal.
4640 
4641            See umask(2)
4642 
4643 
4644        +unalias [-a] name
4645 
4646            The aliases specified by the list of names are removed from the
4647            alias list. The -a option causes all the aliases to be unset.
4648 
4649 
4650        +unset [-fnv] vname
4651 
4652            The variables specified by the list of vnames are unassigned, i.e.,
4653            their values and attributes are erased. Read-only variables cannot
4654            be unset. If the -f option is set, then the names refer to function
4655            names. If the -v option is set, then the names refer to variable
4656            names. The -f option overrides -v. If -n is set and name is a name
4657            reference, then name is unset rather than the variable that it
4658            references. The default is equivalent to -v. Unsetting LINENO,
4659            MAILCHECK, OPTARG, OPTIND, RANDOM, SECONDS, TMOUT, and _ removes
4660            their special meaning even if they are subsequently assigned to.
4661 
4662 
4663        wait [job]
4664 
4665            Wait for the specified job and report its termination status. If
4666            job is not specified, then all currently active child processes are
4667            waited for. The exit status from this command is that of the last
4668            process waited for if job is specified; otherwise it is zero. See
4669            Jobs for a description of the format of job.
4670 
4671 
4672        whence [-afpv] name ...
4673 
4674            For each name, indicate how it would be interpreted if used as a
4675            command name. The -v option produces a more verbose report. The -f
4676            option skips the search for functions. The -p option does a path
4677            search for name even if name is an alias, a function, or a reserved
4678            word. The -a option is similar to the -v option but causes all
4679            interpretations of the specified name to be reported.
4680 
4681 
4682    Invocation
4683        If the shell is invoked by exec(2), and the first character of argument
4684        zero ($0) is -, then the shell is assumed to be a login shell and
4685        commands are read from /etc/profile and then from either .profile in
4686        the current directory or $HOME/.profile, if either file exists. Next,
4687        for interactive shells, commands are read first from /etc/ksh.kshrc,
4688        and then from the file named by performing parameter expansion, command
4689        substitution, and arithmetic substitution on the value of the
4690        environment variable ENV if the file exists. If the -s option is not
4691        present and arg and a file by the name of arg exists, then it reads and
4692        executes this script. Otherwise, if the first arg does not contain a /,
4693        a path search is performed on the first arg to determine the name of
4694        the script to execute. The script arg must have execute permission and
4695        any setuid and setgid settings are ignored. If the script is not found
4696        on the path, arg is processed as if it named a built-in command or
4697        function.
4698 
4699 
4700        Commands are then read as described, and the following options are
4701        interpreted by the shell when it is invoked:
4702 
4703        -c
4704                       If the -c option is present, then commands are read from
4705                       the first arg. Any remaining arguments become positional
4706                       parameters starting at 0.
4707 
4708 
4709        -D
4710                       A list of all double quoted strings that are preceded by
4711                       a $ is printed on standard output and the shell exits.
4712                       This set of strings is subject to language translation
4713                       when the locale is not C or POSIX. No commands are
4714                       executed.
4715 
4716 
4717        -E
4718                       Reads the file named by the ENV variable or by
4719                       $HOME/.kshrc if not defined after the profiles.
4720 
4721 
4722        -i
4723                       If the -i option is present or if the shell input and
4724                       output are attached to a terminal (as told by
4725                       tcgetattr(3C), this shell is interactive. In this case
4726                       TERM is ignored (so that kill 0 does not kill an
4727                       interactive shell) and INTR is caught and ignored (so
4728                       that wait is interruptible). In all cases, QUIT is
4729                       ignored by the shell.
4730 
4731 
4732        -P
4733                       If -P or -o profile is present, the shell is a profile
4734                       shell (see pfexec(1)).
4735 
4736 
4737        -R filename
4738                       The -R filename option is used to generate a cross
4739                       reference database that can be used by a separate
4740                       utility to find definitions and references for variables
4741                       and commands.
4742 
4743 
4744        -r
4745                       If the -r option is present, the shell is a restricted
4746                       shell.
4747 
4748 
4749        -s
4750                       If the -s option is present or if no arguments remain,
4751                       then commands are read from the standard input. Shell
4752                       output, except for the output of the Special Commands
4753                       listed, is written to file descriptor 2.
4754 
4755 
4756 
4757        The remaining options and arguments are described under the set
4758        command.  An optional - as the first argument is ignored.
4759 
4760    rksh93 Only
4761        rksh93 is used to set up login names and execution environments whose
4762        capabilities are more controlled than those of the standard shell.
4763 
4764 
4765        The actions of rksh93 are identical to those of ksh93, except that the
4766        following are disallowed:
4767 
4768            o      Unsetting the restricted option
4769 
4770            o      Changing directory. See cd(1).
4771 
4772            o      Setting or unsetting the value or attributes of SHELL, ENV,
4773                   FPATH, or PATH
4774 
4775            o      Specifying path or command names containing /,
4776 
4777            o      Redirecting output (>, >|, <>, and >>).
4778 
4779            o      Adding or deleting built-in commands.
4780 
4781            o      Using command -p to invoke a command.
4782 
4783 
4784        These restrictions are enforced after .profile and the ENV files are
4785        interpreted.
4786 
4787 
4788        When a command to be executed is found to be a shell procedure, rksh93
4789        invokes ksh93 to execute it. Thus, it is possible to provide to the
4790        end-user shell procedures that have access to the full power of the
4791        standard shell, while imposing a limited menu of commands. This scheme
4792        assumes that the end-user does not have write and execute permissions
4793        in the same directory. The net effect of these rules is that the writer
4794        of the .profile has complete control over user actions, by performing
4795        guaranteed setup actions and leaving the user in an appropriate
4796        directory (probably not the login directory). The system administrator
4797        often sets up a directory of commands, for example, /usr/rbin, that can
4798        be safely invoked by rksh.
4799 
4800 USAGE
4801        See largefile(5) for the description of the behavior of ksh93 and
4802        rksh93 when encountering files greater than or equal to 2 Gbyte ( 2^31
4803        bytes).
4804 
4805 EXIT STATUS
4806        The following exit values are returned:
4807 
4808        non-zero
4809 
4810            Returns non-zero when errors, such as syntax errors, are detected
4811            by the shell.
4812 
4813            If the shell is being used non-interactively, then execution of the
4814            shell file is abandoned unless the error occurs inside a sub-shell
4815            in which case the sub-shell is abandoned.
4816 
4817 
4818        exit status of last command executed
4819 
4820            Returns the exit status of the last command executed.
4821 
4822            Run time errors detected by the shell are reported by printing the
4823            command or function name and the error condition. If the line
4824            number that the error occurred on is greater than one, then the
4825            line number is also printed in square brackets ([]) after the
4826            command or function name.
4827 
4828            See the ksh93 exit command for additional details.
4829 
4830 
4831 FILES
4832        /etc/profile
4833 
4834            The system initialization file, executed for login shells.
4835 
4836 
4837        /etc/ksh.kshrc
4838 
4839            The system wide startup file, executed for interactive shells.
4840 
4841 
4842        $HOME/.profile
4843 
4844            The personal initialization file, executed for login shells after
4845            /etc/profile.
4846 
4847 
4848        $HOME/.kshrc
4849 
4850            Default personal initialization file, executed after
4851            /etc/ksh.kshrc, for interactive shells when ENV is not set.
4852 
4853 
4854        /etc/suid-profile
4855 
4856            Alternative initialization file, executed instead of the personal
4857            initialization file when the real and effective user or group id do
4858            not match.
4859 
4860 
4861        /dev/null
4862 
4863            NULL device.
4864 
4865 
4866 AUTHORS
4867        David Korn, dgk@research.att.com
4868 
4869 ATTRIBUTES
4870        See attributes(5) for descriptions of the following attributes:
4871 
4872 
4873 
4874 
4875        +--------------------+-----------------+
4876        |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
4877        +--------------------+-----------------+
4878        |Interface Stability | See below.      |
4879        +--------------------+-----------------+
4880 
4881 
4882        The scripting interface is Uncommitted. The environment variables,
4883        .paths feature, and editing modes are Volatile.
4884 
4885 SEE ALSO
4886        cat(1), cd(1), chmod(1), cut(1), date(1), egrep(1), echo(1), egrep(1),
4887        env(1), fgrep(1), grep(1), login(1), newgrp(1), paste(1), pfexec(1),
4888        printf(1), stty(1), test(1), umask(1), vi(1), dup(2), exec(2), fork(2),
4889        ioctl(2), lseek(2), pathconf(2), pipe(2), sysconf(3C), ulimit(2),
4890        umask(2), rand(3C), tcgetattr(3C), wait(3C), a.out(4), profile(4),
4891        attributes(5), environ(5), largefile(5), standards(5)
4892 
4893 
4894        Bolsky, Morris I. and Korn, David G., The New KornShell Command and
4895        Programming Language, Prentice Hall, 1995.
4896 
4897 
4898        POSIX-Part 2: Shell and Utilities, IEEE Std 1003.2-1992, ISO/IEC
4899        9945-2, IEEE, 1993.
4900 
4901 NOTES
4902        ksh93 scripts should choose shell function names outside the namespace
4903        used by reserved keywords of the ISO C99, C++ and JAVA languages to
4904        avoid collisions with future enhancements to ksh93.
4905 
4906 
4907        If a command is executed, and then a command with the same name is
4908        installed in a directory in the search path before the directory where
4909        the original command was found, the shell continues to exec the
4910        original command. Use the -t option of the alias command to correct
4911        this situation.
4912 
4913 
4914        Some very old shell scripts contain a caret (^) as a synonym for the
4915        pipe character (|).
4916 
4917 
4918        Using the hist built-in command within a compound command causes the
4919        whole command to disappear from the history file.
4920 
4921 
4922        The built-in command . file reads the whole file before any commands
4923        are executed. alias and unalias commands in the file do not apply to
4924        any commands defined in the file.
4925 
4926 
4927        Traps are not processed while a job is waiting for a foreground
4928        process. Thus, a trap on CHLD is not executed until the foreground job
4929        terminates.
4930 
4931 
4932        It is a good idea to leave a space after the comma operator in
4933        arithmetic expressions to prevent the comma from being interpreted as
4934        the decimal point character in certain locales.
4935 
4936 
4937        There might be some restrictions on creating a .paths file which is
4938        portable across other operating systems.
4939 
4940 
4941        If the system supports the 64-bit instruction set, /bin/ksh93 executes
4942        the 64-bit version of ksh93.
4943 
4944 
4945 
4946                                 January 6, 2020                       KSH93(1)