Print this page
13405 ksh93 update to 2012-08-01: part 4: man page
Change-ID: If0d23a7414155253671c169228cb81ea13abbfc1

*** 125,135 **** command executes the do list once for each positional parameter that is set starting from 1. Execution ends when there are no more words in the list. See Parameter Expansion. ! (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done The arithmetic expression expr1 is evaluated first. The arithmetic expression expr2 is repeatedly evaluated until it evaluates to zero and when non-zero, list is executed and the arithmetic expression expr3 evaluated. If any expression is omitted, then it behaves as --- 125,135 ---- command executes the do list once for each positional parameter that is set starting from 1. Execution ends when there are no more words in the list. See Parameter Expansion. ! for (( [expr1] ; [expr2] ; [expr3] )) ;do list ;done The arithmetic expression expr1 is evaluated first. The arithmetic expression expr2 is repeatedly evaluated until it evaluates to zero and when non-zero, list is executed and the arithmetic expression expr3 evaluated. If any expression is omitted, then it behaves as
*** 192,208 **** evaluation described in this manual page. If the value of the arithmetic expression is non-zero, the exit status is 0. Otherwise the exit status is 1. ! (list;) Execute list in a separate environment. If two adjacent open parentheses are needed for nesting, a SPACE must be inserted to avoid evaluation as an arithmetic command as described in this section. list is simply executed. Unlike the metacharacters, ( and ), { and } are reserved words and must occur at the beginning of a line or after a ; to be recognized. --- 192,211 ---- evaluation described in this manual page. If the value of the arithmetic expression is non-zero, the exit status is 0. Otherwise the exit status is 1. ! (list) Execute list in a separate environment. If two adjacent open parentheses are needed for nesting, a SPACE must be inserted to avoid evaluation as an arithmetic command as described in this section. + + { list;} + list is simply executed. Unlike the metacharacters, ( and ), { and } are reserved words and must occur at the beginning of a line or after a ; to be recognized.
*** 215,225 **** function varname { list ;} varname () { list ;} Define a function which is referenced by varname. A function whose ! varname contains a . is called a discipline function and the portion of the varname preceding the last . must refer to an existing variable. The body of the function is the list of commands between { and }. A function defined with the function varname syntax can also be used --- 218,228 ---- function varname { list ;} varname () { list ;} Define a function which is referenced by varname. A function whose ! varname contains a dot (.) is called a discipline function and the portion of the varname preceding the last . must refer to an existing variable. The body of the function is the list of commands between { and }. A function defined with the function varname syntax can also be used
*** 226,235 **** --- 229,244 ---- as an argument to the . special built-in command to get the equivalent behavior as if the varname() syntax were used to define it. See Functions. + namespace identifier { list }; + + Defines or uses the name space identifier and runs the commands in + list in this name space. See Name Spaces. + + time [ pipeline ] If pipeline is omitted, the user and system time for the current shell and completed child processes is printed on standard error. Otherwise, pipeline is executed and the elapsed time as well as the
*** 240,249 **** --- 249,259 ---- The following reserved words are recognized as reserved only when they are the first word of a command and are not quoted: + case do done else elif
*** 261,278 **** [[ ]] ! Variable Assignments One or more variable assignments can start a simple command or can be ! arguments to the typeset, export, or readonly special built-in commands. The syntax for an assignment is of the form: varname=word varname[word]=word No space is permitted between varname and the = or between = and ! word. varname=(assignlist) No space is permitted between varname and the =. An assignlist can --- 271,288 ---- [[ ]] ! Variable Assignments One or more variable assignments can start a simple command or can be ! arguments to the typeset, enum, export, or readonly special built-in commands. The syntax for an assignment is of the form: varname=word varname[word]=word No space is permitted between varname and the = or between = and ! word. The variable varname is unset before the assignment. varname=(assignlist) No space is permitted between varname and the =. An assignlist can
*** 305,339 **** Nested variable assignment. Multiple assignments can be specified by separating each of them with a ;. The previous value is unset before the assignment. In addition, a += can be used in place of the = to signify adding to or appending to the previous value. When += is applied to an arithmetic type, word is evaluated as an arithmetic expression and added to the current value. When applied to a string variable, the value defined by word is appended to the value. For compound assignments, the previous value is not unset and the new values are appended to the current ones provided that the types are compatible. Comments A word beginning with # causes that word and all the following characters up to a NEWLINE to be commented, or ignored. Aliasing The first word of each command is replaced by the text of an alias if an alias for this word has been defined. An alias name consists of any number of characters excluding metacharacters, quoting characters, file expansion characters, parameter expansion characters, command ! substitution characters, and =. The replacement string can contain any ! valid shell script including the metacharacters listed in the Commands ! section. The first word of each command in the replaced text, other ! than any that are in the process of being replaced, are tested for ! aliases. If the last character of the alias value is a BLANK then the ! word following the alias is also checked for alias substitution. Aliases can be used to redefine built-in commands but cannot be used to redefine the reserved words listed in the Commands section. Aliases can be created and listed with the alias command and can be removed with --- 315,363 ---- Nested variable assignment. Multiple assignments can be specified by separating each of them with a ;. The previous value is unset before the assignment. + + . filename + + Include the assignment commands contained in filename. + In addition, a += can be used in place of the = to signify adding to or appending to the previous value. When += is applied to an arithmetic type, word is evaluated as an arithmetic expression and added to the current value. When applied to a string variable, the value defined by word is appended to the value. For compound assignments, the previous value is not unset and the new values are appended to the current ones provided that the types are compatible. + The right hand side of a variable assignment undergoes all the + expansion listed below except word splitting, brace expansion, and + file name generation. When the left hand side is an assignment is + a compound variable and the right hand is the name of a compound + variable, the compound variable on the right will be copied or + appended to the compound variable on the left. + + Comments A word beginning with # causes that word and all the following characters up to a NEWLINE to be commented, or ignored. Aliasing The first word of each command is replaced by the text of an alias if an alias for this word has been defined. An alias name consists of any number of characters excluding metacharacters, quoting characters, file expansion characters, parameter expansion characters, command ! substitution characters, the characters / and =. The replacement string ! can contain any valid shell script including the metacharacters listed ! in the Commands section. The first word of each command in the replaced ! text, other than any that are in the process of being replaced, are ! tested for aliases. If the last character of the alias value is a BLANK ! then the word following the alias is also checked for alias ! substitution. Aliases can be used to redefine built-in commands but cannot be used to redefine the reserved words listed in the Commands section. Aliases can be created and listed with the alias command and can be removed with
*** 346,355 **** --- 370,380 ---- The following aliases are compiled into the shell but can be unset or redefined: autoload='typeset -fu' command='command ' + compound='typeset -C' fc=hist float='typeset -lE' functions='typeset -f' hash='alias -t --' history='hist -l'
*** 385,415 **** is attempted when the value of the assignment begins with a ~, and when a ~ appears after a colon (:). The : also terminates a ~ login name. Command Substitution The standard output from a command enclosed in parentheses preceded by ! a dollar sign ($) or a pair of grave accents (``) can be used as part ! or all of a word. Trailing NEWLINEs are removed. In the second ! (obsolete) form, the string between the quotes is processed for special ! quoting characters before the command is executed. See Quoting. The command substitution $(cat file) can be replaced by the equivalent but faster $(<file). The command substitution $(n<#) expands to the ! current byte offset for file descriptor n. Arithmetic Substitution An arithmetic expression enclosed in double parentheses preceded by a dollar sign ( $((arithmetic_expression))) is replaced by the value of the arithmetic expression within the double parentheses. Process Substitution - Process substitution is only available on versions of the UNIX - operating system that support the /dev/fd directory for naming open - files. - - Each command argument of the form <(list) or >(list) runs process list asynchronously connected to some file in /dev/fd. The name of this file becomes the argument to the command. If the form with > is selected then writing on this file provides input for list. If < is used, then the file passed as an argument contains the output of the list process. --- 410,442 ---- is attempted when the value of the assignment begins with a ~, and when a ~ appears after a colon (:). The : also terminates a ~ login name. Command Substitution The standard output from a command enclosed in parentheses preceded by ! a dollar sign ( $(list) ), or in a brace group preceded by a dollar ! sign ( ${ list;} ), or in a pair of grave accents (``) can be used as ! part or all of a word. Trailing NEWLINEs are removed. In the second ! case, the { and } are treated as a reserved words so that { must be ! followed by a blank and } must appear at the beginning of the line or ! follow a ;. In the third (obsolete) form, the string between the quotes ! is processed for special quoting characters before the command is ! executed. See Quoting. The command substitution $(cat file) can be replaced by the equivalent but faster $(<file). The command substitution $(n<#) expands to the ! current byte offset for file descriptor n. Except for the second form, ! the command list is run in a subshell so that no side effects are ! possible. For the second form, the final } will be recognized as a ! reserved word after any token. Arithmetic Substitution An arithmetic expression enclosed in double parentheses preceded by a dollar sign ( $((arithmetic_expression))) is replaced by the value of the arithmetic expression within the double parentheses. Process Substitution Each command argument of the form <(list) or >(list) runs process list asynchronously connected to some file in /dev/fd. The name of this file becomes the argument to the command. If the form with > is selected then writing on this file provides input for list. If < is used, then the file passed as an argument contains the output of the list process.
*** 427,436 **** --- 454,467 ---- the results together, and sends it to the processes process1 and process2. It also displays the results to the standard output. The file, which is passed as an argument to the command, is a UNIX pipe(2). Programs that expect to lseek(2) on the file do not work. + Process substitution of the form <(list) can also be used with the < + redirection operator which causes the output of list to be standard + input or the input for whatever file descriptor is specified. + Parameter Expansion A parameter is a variable, one or more digits, or any of the characters *, @, #, ?, -, $, and !. A variable is denoted by a vname. To create a variable whose vname contains a ., a variable whose vname consists of everything before the last . must already exist. A variable has a value
*** 442,456 **** The shell supports both indexed and associative arrays. An element of an array variable is referenced by a subscript. A subscript for an indexed array is denoted by an arithmetic expression, (see Arithmetic ! Evaluation), between a [ and a ]. Use set -A vname value ... to assign ! values to an indexed array. The value of all subscripts must be in the ! range of 0 through 1,048,575. Indexed arrays do not need to be ! declared. Any reference to a variable with a valid subscript is legal ! and an array is created if necessary. An associative array is created with the -A option to typeset. A subscript for an associative array is denoted by a string enclosed between [ and ]. --- 473,490 ---- The shell supports both indexed and associative arrays. An element of an array variable is referenced by a subscript. A subscript for an indexed array is denoted by an arithmetic expression, (see Arithmetic ! Evaluation), between a [ and a ]. To assign values to an indexed ! array, use vname=(value ...) or set -A vname value ... . The value of ! all subscripts must be in the range of 0 through 4,194,303. A negative ! subscript is treated as an offset from the maximum current index +1 so ! that -1 refers to the last element. Indexed arrays can be declared ! with the -a option to typeset. Indexed arrays need not be declared. Any ! reference to a variable with a valid subscript is legal and an array ! will be created if necessary. An associative array is created with the -A option to typeset. A subscript for an associative array is denoted by a string enclosed between [ and ].
*** 469,526 **** or vname[subscript]=value [vname[subscript]=value] ... ! No space is allowed before or after the =. A nameref is a variable that ! is a reference to another variable. A nameref is created with the -n ! attribute of typeset. The value of the variable at the time of the ! typeset command becomes the variable that is referenced whenever the ! nameref variable is used. The name of a nameref cannot contain a dot ! (.). When a variable or function name contains a ., and the portion of ! the name up to the first . matches the name of a nameref, the variable ! referred to is obtained by replacing the nameref portion with the name ! of the variable referenced by the nameref. If a nameref is used as the ! index of a for loop, a name reference is established for each item in ! the list. A nameref provides a convenient way to refer to the variable ! inside a function whose name is passed as an argument to a function. ! For example, if the name of a variable is passed as the first argument ! to a function, the command typeset -n var=$1 inside the function causes references and assignments to var to be references and assignments to the variable whose name has been passed ! to the function. If either of the floating point attributes, -E, or -F, or the integer attribute, -i, is set for vname, then the value is subject to arithmetic evaluation as described in this manual page. Positional parameters, parameters denoted by a number, can be assigned values with the set special built-in command. Parameter $0 is set from ! argument zero when the shell is invoked. The character $ is used to ! introduce substitutable parameters. ${parameter} The shell reads all the characters from ${ to the matching } as part of the same word even if it contains braces or metacharacters. The value, if any, of the parameter is substituted. The braces are required when parameter is followed by a letter, digit, or ! underscore that is not to be interpreted as part of its name, when ! the variable name contains a ., or when a variable is subscripted. ! If parameter is one or more digits then it is a positional ! parameter. A positional parameter of more than one digit must be ! enclosed in braces. If parameter is * or @, then all the positional ! parameters, starting with $1, are substituted and separated by a ! field separator character. If an array vname with subscript * or @ ! is used, then the value for each of the elements is substituted, ! separated by the first character of the value of IFS. ${#parameter} If parameter is * or @, the number of positional parameters is --- 503,574 ---- or vname[subscript]=value [vname[subscript]=value] ... + Note that no space is allowed before or after the =. + Attributes assigned by the typeset special built-in command apply to + all elements of the array. An array element can be a simple variable, + a compound variable or an array variable. An element of an indexed + array can be either an indexed array or an associative array. An + element of an associative array can also be either. To refer to an + array element that is part of an array element, concatenate the + subscript in brackets. For example, to refer to the foobar element of + an associative array that is defined as the third element of the + indexed array, use ${vname[3][foobar]} ! A nameref is a variable that is a reference to another variable. A ! nameref is created with the -n attribute of typeset. The value of the ! variable at the time of the typeset command becomes the variable that ! is referenced whenever the nameref variable is used. The name of a ! nameref cannot contain a dot (.). When a variable or function name ! contains a dot (.) and the portion of the name up to the first . ! matches the name of a nameref, the variable referred to is obtained by ! replacing the nameref portion with the name of the variable referenced ! by the nameref. If a nameref is used as the index of a for loop, a name ! reference is established for each item in the list. A nameref provides ! a convenient way to refer to the variable inside a function whose name ! is passed as an argument to a function. For example, if the name of a ! variable is passed as the first argument to a function, the command typeset -n var=$1 inside the function causes references and assignments to var to be references and assignments to the variable whose name has been passed ! to the function. If any of the floating point attributes, -E,-F or -X, or the integer attribute, -i, is set for vname, then the value is subject to arithmetic evaluation as described in this manual page. Positional parameters, parameters denoted by a number, can be assigned values with the set special built-in command. Parameter $0 is set from ! argument zero when the shell is invoked. + The character $ is used to introduce substitutable parameters. + ${parameter} The shell reads all the characters from ${ to the matching } as part of the same word even if it contains braces or metacharacters. The value, if any, of the parameter is substituted. The braces are required when parameter is followed by a letter, digit, or ! underscore that is not to be interpreted as part of its name or ! when the variable name contains a dot (.). The braces are also ! required when a variable is subscripted unless it is part of an ! Arithmetic Expression or a Conditional Expression. If parameter is ! one or more digits then it is a positional parameter. A positional ! parameter of more than one digit must be enclosed in braces. If ! parameter is * or @, then all the positional parameters, starting ! with $1, are substituted and separated by a field separator ! character. If an array vname with last subscript * or @ is used, or ! for index arrays of the form sub1 .. sub2 is used, then the value ! for each of the elements between sub1 and sub2 inclusive (or all ! elements for * and @) is substituted, separated by the first ! character of the value of IFS. ${#parameter} If parameter is * or @, the number of positional parameters is
*** 531,555 **** ${#vname[*]} ${#vname[@]} The number of elements in the array vname is substituted. ${!vname} Expands to the name of the variable referred to by vname. This is vname except when vname is a name reference. ${!vname[subscript]} ! Expands to name of the subscript unless subscript is * or @. When ! subscript is *, the list of array subscripts for vname is ! generated. For a variable that is not an array, the value is 0 if ! the variable is set. Otherwise it is null. When subscript is @, it ! is the same as $ {vname[*]}, except that when used in double ! quotes, each array subscript yields a separate argument. ${!prefix*} Expands to the names of the variables whose names begin with --- 579,611 ---- ${#vname[*]} ${#vname[@]} The number of elements in the array vname is substituted. + ${@vname} + Expands to the type name or attributes of the variable referred to + by vname. See Type Variables. + + ${!vname} Expands to the name of the variable referred to by vname. This is vname except when vname is a name reference. ${!vname[subscript]} ! Expands to name of the subscript unless subscript is * or @, or of ! the form sub1 .. sub2. When subscript is *, the list of array ! subscripts for vname is generated. For a variable that is not an ! array, the value is 0 if the variable is set, otherwise it is null. ! When subscript is @, it is the same as $ {vname[*]}, except that ! when used in double quotes, each array subscript yields a separate ! argument. When subscript is of the form sub1 .. sub2 it expands to ! the list of subscripts between sub1 and sub2 inclusive using the ! same quoting rules as @. ${!prefix*} Expands to the names of the variables whose names begin with
*** 559,635 **** ${parameter:-word} If parameter is set and is non-null then substitute its value. Otherwise substitute word. - word is not evaluated unless it is to be used as the substituted - string. - In the following example, pwd is executed only if d is not set or - is NULL: - - print ${d:-$(pwd)} - - - If the colon (: ) is omitted from the expression, the shell only - checks whether parameter is set or not. - - ${parameter:=word} If parameter is not set or is null, set it to word. The value of the parameter is then substituted. Positional parameters cannot be assigned to in this way. - word is not evaluated unless it is to be used as the substituted - string. - In the following example, pwd is executed only if d is not set or - is NULL: - - print ${d:-$(pwd)} - - - If the colon (:) is omitted from the expression, the shell only - checks whether parameter is set or not. - - ${parameter:?word} If parameter is set and is non-null, substitute its value. Otherwise, print word and exit from the shell , if the shell is not interactive. If word is omitted then a standard message is printed. - word is not evaluated unless it is to be used as the substituted - string. - In the following example, pwd is executed only if d is not set or - is NULL: - - print ${d:-$(pwd)} - - - If the colon (: ) is omitted from the expression, the shell only - checks whether parameter is set or not. - - ${parameter:+word} If parameter is set and is non-null, substitute word. Otherwise substitute nothing. ! word is not evaluated unless it is to be used as the substituted ! string. - In the following example, pwd is executed only if d is not set or - is NULL: - print ${d:-$(pwd)} ! If the colon (:) is omitted from the expression, the shell only ! checks whether parameter is set or not. ${parameter:offset:length} ${parameter:offset} --- 615,653 ---- ${parameter:-word} If parameter is set and is non-null then substitute its value. Otherwise substitute word. ${parameter:=word} If parameter is not set or is null, set it to word. The value of the parameter is then substituted. Positional parameters cannot be assigned to in this way. ${parameter:?word} If parameter is set and is non-null, substitute its value. Otherwise, print word and exit from the shell , if the shell is not interactive. If word is omitted then a standard message is printed. ${parameter:+word} If parameter is set and is non-null, substitute word. Otherwise substitute nothing. ! In the above, word is not evaluated unless it is to be used as the ! substituted string. In the following example, pwd is executed only if d ! is not set or is NULL: print ${d:-$(pwd)} ! If the colon (:) is omitted from the expression, the shell only checks ! whether parameter is set or not. ${parameter:offset:length} ${parameter:offset}
*** 736,748 **** the name of the matching MAIL file when checking for mail. ! ! The process number of the last background command ! invoked or the most recent job put in the background ! with the bg built-in command. .sh.command When processing a DEBUG trap, this variable contains the current command line that is about to run. --- 754,770 ---- the name of the matching MAIL file when checking for mail. ! ! The process id or the pool name and job number of ! the last background command invoked or the most ! recent job put in the background with the bg built- ! in command. Background jobs started in a named pool ! with be in the form pool.number where pool is the ! pool name and number is the job number within that ! pool. .sh.command When processing a DEBUG trap, this variable contains the current command line that is about to run.
*** 796,805 **** --- 818,833 ---- the ith sub-match. The .sh.match variable is unset when the variable that has expanded is assigned a new value. + .sh.math + Used for defining arithmetic functions (see + Arithmetic evaluation) and stores the list of user- + defined arithmetic functions. + + .sh.name Set to the name of the variable at the time that a discipline function is invoked.
*** 814,823 **** --- 842,855 ---- .sh.value Set to the value of the variable at the time that the set or append discipline function is invoked. + When a user-defined arithmetic function is invoked, + the value of .sh.value is saved and .sh.value is set + to long double precision floating point. .sh.value + is restored when the function returns. .sh.version Set to a value that identifies the version of this shell.
*** 871,881 **** --- 903,920 ---- returned upon reference is the value that was assigned plus the number of seconds since the assignment. + SHLVL + An integer variable the is incremented each time the + shell is invoked and is exported. If SHLVL is not + in the environment when the shell is invoked, it is + set to 1. + + The following variables are used by the shell: CDPATH Defines the search path for the cd command.
*** 980,989 **** --- 1019,1035 ---- then two adjacent tab characters delimit a null field. The shell specifies a default value to IFS. + JOBMAX + This variable defines the maximum number running + background jobs that can run at a time. When this limit + is reached, the shell will wait for a job to complete + before staring a new job. + + LANG This variable determines the locale category for any category not specifically selected with a variable starting with LC_ or LANG.
*** 1248,1263 **** [...] Match any one of the enclosed characters. A pair of characters separated by - matches any character lexically between the pair, inclusive. If the first character ! following the opening [ is a !, any character not enclosed ! is matched. A - can be included in the character set by ! putting it as the first or last character. Within [ and ], ! character classes can be specified with the syntax [:class:] ! where class is one of the following classes defined in the ! ANSI-C standard: alnum alpha blank cntrl digit graph lower print punct space upper word xdigit --- 1294,1309 ---- [...] Match any one of the enclosed characters. A pair of characters separated by - matches any character lexically between the pair, inclusive. If the first character ! following the opening [ is a ! or ^, any character not ! enclosed is matched. A - can be included in the character ! set by putting it as the first or last character. Within [ ! and ], character classes can be specified with the syntax ! [:class:] where class is one of the following classes ! defined in the ANSI-C standard: alnum alpha blank cntrl digit graph lower print punct space upper word xdigit
*** 1393,1404 **** A pattern can contain sub-patterns of the form ~(options:pattern-list), where either options or :pattern-list can be omitted. Unlike the other compound patterns, these sub-patterns are not counted in the numbered ! sub-patterns. If options is present, it can consist of one or more of ! the following: + Enable the following options. This is the default. --- 1439,1451 ---- A pattern can contain sub-patterns of the form ~(options:pattern-list), where either options or :pattern-list can be omitted. Unlike the other compound patterns, these sub-patterns are not counted in the numbered ! sub-patterns. :pattern-list must be omitted for options F, G, N and V ! below. If options is present, it can consist of one or more of the ! following: + Enable the following options. This is the default.
*** 1452,1486 **** Right anchor the pattern. This is the default for K style patterns. - If both options and :pattern-list are specified, then the options apply - only to pattern-list. Otherwise, these options remain in effect until - they are disabled by a subsequent ~(...) or at the end of the sub- - pattern containing ~(...). ! Quoting ! Each of the metacharacters listed in the Definitions has a special ! meaning to the shell. - g - File the longest match (greedy). This is the default. - i - Treat the match as case insensitive. - If both options and :pattern-list are specified, then the options apply ! only to pattern-list. Otherwise, the options remain in effect until they are disabled by a subsequent ~(...) or at the end of the sub- pattern containing ~(...). ! Each of the metacharacters listed in the Definitions section of this manual page has a special meaning to the shell and causes termination of a word unless quoted. A character can be quoted, that is, made to stand for itself, by preceding it with a backslash (\). The pair \NEWLINE is removed. All characters enclosed between a pair of single --- 1499,1531 ---- Right anchor the pattern. This is the default for K style patterns. + X + The remainder of the pattern uses augmented regular expression + syntax. ! P ! The remainder of the pattern uses perl(1) regular expression ! syntax. Not all perl regular expression syntax is currently ! implemented. + V + The remainder of the pattern uses System V regular expression + syntax. If both options and :pattern-list are specified, then the options apply ! only to pattern-list. Otherwise, these options remain in effect until they are disabled by a subsequent ~(...) or at the end of the sub- pattern containing ~(...). ! Quoting Each of the metacharacters listed in the Definitions section of this manual page has a special meaning to the shell and causes termination of a word unless quoted. A character can be quoted, that is, made to stand for itself, by preceding it with a backslash (\). The pair \NEWLINE is removed. All characters enclosed between a pair of single
*** 1516,1527 **** cause the string to be replaced by a locale specific string otherwise. The meaning of $* and $@ is identical when not quoted or when used as a variable assignment value or as a file name. However, when used as a command argument, "$*" is equivalent to "$1d$2d...", where d is the first character of the IFS variable, whereas "$@" is equivalent to "$1" ! "$2" .... Inside grave quote marks (``), \fR quotes the characters \, ! `, and $. If the grave quotes occur within double quotes, then \ also quotes the character ". The special meaning of reserved words or aliases can be removed by quoting any character of the reserved word. The recognition of function --- 1561,1572 ---- cause the string to be replaced by a locale specific string otherwise. The meaning of $* and $@ is identical when not quoted or when used as a variable assignment value or as a file name. However, when used as a command argument, "$*" is equivalent to "$1d$2d...", where d is the first character of the IFS variable, whereas "$@" is equivalent to "$1" ! "$2" .... Inside grave quote marks (``), \ quotes the characters \, `, ! and $. If the grave quotes occur within double quotes, then \ also quotes the character ". The special meaning of reserved words or aliases can be removed by quoting any character of the reserved word. The recognition of function
*** 1535,1553 **** the built-in command printf that correspond to numeric format specifiers in the format operand. See printf(1). Evaluations are performed using double precision floating point arithmetic or long double precision floating point for systems that provide this data type. Floating point constants follow the ANSI-C programming language ! floating point conventions. Integer constants follow the ANSI-C ! programming language integer constant conventions although only single ! byte character constants are recognized and character casts are not ! recognized. Constants can be of the form [base#]n where base is a ! decimal number between two and sixty-four representing the arithmetic ! base and n is a number in that base. The digits greater than 9 are ! represented by the lower case letters, the upper case letters, @, and _ ! respectively. For bases less than or equal to 36, upper and lower case ! characters can be used interchangeably. An arithmetic expression uses the same syntax, precedence, and associativity of expression as the C language. All the C language operators that apply to floating point quantities can be used. In --- 1580,1600 ---- the built-in command printf that correspond to numeric format specifiers in the format operand. See printf(1). Evaluations are performed using double precision floating point arithmetic or long double precision floating point for systems that provide this data type. Floating point constants follow the ANSI-C programming language ! floating point conventions. The floating point constants Nan and Inf ! can be used to represent "not a number" and infinity respectively. ! Integer constants follow the ANSI-C programming language integer ! constant conventions although only single byte character constants are ! recognized and character casts are not recognized. Constants can be of ! the form [base#]n where base is a decimal number between two and sixty- ! four representing the arithmetic base and n is a number in that base. ! The digits greater than 9 are represented by the lower case letters, ! the upper case letters, @, and _ respectively. For bases less than or ! equal to 36, upper and lower case characters can be used ! interchangeably. An arithmetic expression uses the same syntax, precedence, and associativity of expression as the C language. All the C language operators that apply to floating point quantities can be used. In
*** 1561,1600 **** Any of the following math library functions that are in the C math library can be used within an arithmetic expression: ! abs acos acosh asin asinh atan atan2 atanh cbrt ! copysign cos cosh erf erfc exp exp2 expm1 fabs ! fdim finite floor fma fmax fmod hypot ilogb ! int isinf isnan lgamma log log2 logb ! nearbyint nextafter nexttoward pow remainder ! rint round sin sinh sqrt tan tanh tgamma trunc An internal representation of a variable as a double precision floating ! point can be specified with the -E [n] or -F [n] option of the typeset ! special built-in command. The -E option causes the expansion of the ! value to be represented using scientific notation when it is expanded. ! The optional option argument n defines the number of significant ! figures. The -F option causes the expansion to be represented as a ! floating decimal number when it is expanded. The optional option ! argument n defines the number of places after the decimal point in this ! case. An internal integer representation of a variable can be specified with the -i [n] option of the typeset special built-in command. The optional option argument n specifies an arithmetic base to be used when expanding the variable. If you do not specify an arithmetic base, base 10 is used. Arithmetic evaluation is performed on the value of each assignment to a ! variable with the -E, -F, or -i option. Assigning a floating point number to a variable whose type is an integer causes the fractional part to be truncated. Prompting When used interactively, the shell prompts with the value of PS1 after --- 1608,1666 ---- Any of the following math library functions that are in the C math library can be used within an arithmetic expression: ! rint round sin sinh sqrt tan tanh tgamma trunc abs acos ! acosh asin asinh atan atan2 atanh cbrt ceil copysign cos ! cosh erf erfc exp exp2 expm1 fabs fpclassify fdim finite ! floor fma fmax fmin fmod hypot ilogb int isfinite sinf isnan ! isnormal issubnormal issubor- dered iszero j0 j1 jn lgamma ! log log10 log2 logb nearbyint nextafter nexttoward pow ! remainder rint round scanb signbit sin sinh sqrt tan tanh ! tgamma trunc y0 y1 yn + In addition, arithmetic functions can be defined as shell functions + with a variant of the function name syntax: + + function .sh.math.name ident ... { list ;} + where name is the function name used in the arithmetic expression + and each identified ident is a name reference to the long double + precision floating point argument. The value of .sh.value when the + function returns is the value of this function. User defined + functions can take up to 3 arguments and override C math library + functions. + + + An internal representation of a variable as a double precision floating ! point can be specified with the -E [n], -F [n], or -X [n] options of ! the typeset special built-in command. The -E option causes the ! expansion of the value to be represented using scientific notation when ! it is expanded. The optional option argument n defines the number of ! significant figures. The -F option causes the expansion to be ! represented as a floating decimal number when it is expanded. The ! optional option argument n defines the number of places after the ! decimal point in this case. The -X option causes the expansion to be ! represented using the %a format defined by ISO C-99. The optional ! option argument n defines the number of places after the decimal (or ! radix) point in this case. + An internal integer representation of a variable can be specified with the -i [n] option of the typeset special built-in command. The optional option argument n specifies an arithmetic base to be used when expanding the variable. If you do not specify an arithmetic base, base 10 is used. Arithmetic evaluation is performed on the value of each assignment to a ! variable with the -E, -F, -X or -i option. Assigning a floating point number to a variable whose type is an integer causes the fractional part to be truncated. Prompting When used interactively, the shell prompts with the value of PS1 after
*** 1696,1705 **** --- 1762,1775 ---- -r file True, if file exists and is readable by current process. + -R name + True if variable name is a name reference. + + -s file True, if file exists and has size greater than zero.
*** 1715,1724 **** --- 1785,1799 ---- -u file True, if file exists and it has its setuid bit set. + -v name + True, if variable name is a valid variable name + and is set. + + -w file True, if file exists and is writable by current process.
*** 1784,1799 **** string1 > string2 True, if string1 comes after string2 based on ASCII value of their characters. ! ! In each of the following expressions, if file is of the form /dev/fd/n, where n is an integer, the test is applied to the open file whose ! descriptor number is n. The following obsolete arithmetic comparisons ! are supported: exp1 -eq exp2 True, if exp1 is equal to exp2. exp1 -ge exp2 --- 1859,1875 ---- string1 > string2 True, if string1 comes after string2 based on ASCII value of their characters. ! In each of the above expressions, if file is of the form /dev/fd/n, where n is an integer, the test is applied to the open file whose ! descriptor number is n. + + The following obsolete arithmetic comparisons are also supported: + exp1 -eq exp2 True, if exp1 is equal to exp2. exp1 -ge exp2
*** 1873,1882 **** --- 1949,1965 ---- >|word Same as >, except that it overrides the noclobber option. + >;word + Write output to a temporary file. If the command + completes successfully rename it to word, otherwise, + delete the temporary file. >;word cannot be used with + the exec(2) built-in. + + >>word Use file word as standard output. If the file exists, then output is appended to it (by first seeking to the end-of-file). Otherwise, the file is created.
*** 2133,2144 **** The variable .sh.name contains the name of the variable for which the discipline function is called, .sh.subscript is the subscript of the variable, and .sh.value contains the value being assigned inside the set discipline function. For the set discipline, changing .sh.value ! changes the value that gets assigned. Jobs If the monitor option of the set command is turned on, an interactive shell associates a job with each pipeline. It keeps a table of current jobs, printed by the jobs command, and assigns them small integer numbers. When a job is started asynchronously with &, the shell prints --- 2216,2309 ---- The variable .sh.name contains the name of the variable for which the discipline function is called, .sh.subscript is the subscript of the variable, and .sh.value contains the value being assigned inside the set discipline function. For the set discipline, changing .sh.value ! changes the value that gets assigned. The variable _ is a reference to ! the variable including the subscript if any. For the set discipline, ! changing .sh.value will change the value that gets assigned. Finally, ! the expansion ${ var.name}, when name is the name of a discipline, and ! there is no variable of this name, is equivalent to the command ! substitution ${var.name;}. + + Name Spaces + Commands and functions that are executed as part of the list of a + namespace command that modify variables or create new ones, create a + new variable whose name is the name of the name space as given by + identifier preceded by two dots (..). When a variable whose name is + name is referenced, it is first searched for using .identifier.name. + Similarly, a function defined by a command in the namespace list is + created using the name space name preceded by two dots (..). + + When the list of a namespace command contains a namespace command, the + names of variables and functions that are created consist of the + variable or function name preceded by the list of identifiers each + preceded by two dots (..). + + Outside of a name space, a variable or function created inside a name + space can be referenced by preceding it with the name space name. + + By default, variables staring with .sh are in the sh name space. + + + Typed Variables + Typed variables provide a way to create data structure and objects. A + type can be defined either by a shared library, by the enum built-in + command described below, or by using the new -T option of the typeset + built-in command. With the -T option of typeset, the type name, + specified as an option argument to -T, is set with a compound variable + assignment that defines the type. Function definitions can appear + inside the compound variable assignment and these become discipline + functions for this type and can be invoked or redefined by each + instance of the type. The function name create is treated specially. It + is invoked for each instance of the type that is created but is not + inherited and cannot be redefined for each instance. + + When a type is defined a special built-in command of that name is + added. These built-ins are declaration commands and follow the same + expansion rules as all the special built-in commands defined below that + are preceded by a dot (.). These commands can subsequently be used + inside further type definitions. The man page for these commands can be + generated by using the --man option or any of the other -- options + described with getopts. The -r, -a, -A, -h and -S options of typeset + are permitted with each of these new built-ins. + + An instance of a type is created by invoking the type name followed by + one or more instance names. Each instance of the type is initialized + with a copy of the sub-variables except for sub-variables that are + defined with the -s option. Variables defined with -S are shared by all + instances of the type. Each instance can change the value of any sub- + variable and can also define new discipline functions of the same names + as those defined by the type definition as well as any standard + discipline names. No additional sub-variables can be defined for any + instance. + + When defining a type, if the value of a sub-variable is not set and the + -r attribute is specified, it causes the sub-variable to be a required + sub-variable. Whenever an instance of a type is created, all required + sub-variables must be specified. These sub-variables become readonly in + each instance. + + When unset is invoked on a sub-variable within a type, and the -r + attribute has not been specified for this field, the value is reset to + the default value associative with the type. Invoking unset on a type + instance not contained within another type deletes all sub-variables + and the variable itself. + + A type definition can be derived from another type definition by + defining the first sub-variable name as _ and defining its type as the + base type. Any remaining definitions will be additions and + modifications that apply to the new type. If the new type name is the + same is that of the base type, the type will be replaced and the + original type will no longer be accessible. + + The typeset command with -T and no option argument or operands will + write all the type definitions to standard output in a form that that + can be read in to create all the types. + + Jobs If the monitor option of the set command is turned on, an interactive shell associates a job with each pipeline. It keeps a table of current jobs, printed by the jobs command, and assigns them small integer numbers. When a job is started asynchronously with &, the shell prints
*** 2168,2185 **** --- 2333,2362 ---- this can be disabled by giving the command sttytostop. If you set this tty option, then background jobs stop when they try to produce output like they do when they try to read input. + A job pool is a collection of jobs started with list & associated with + a name. + + There are several ways to refer to jobs in the shell. A job can be referred to by the process id of any process of the job or by one of the following: %number The job with the specified number. + pool + All the jobs in the job pool named by pool. + + + pool.number + The job number number in the pool named by pool. + + %string Any job whose command line begins with string. %?string
*** 2196,2206 **** --- 2373,2388 ---- %- Previous job. + In addition, unless noted otherwise, wherever a job can be specified, + the name of a background job pool can be used to represent all the jobs + in that pool. + + The shell learns immediately whenever a process changes state. It normally informs you whenever a job becomes blocked so that no further progress is possible, but only just before it prints a prompt. This is done so that it does not otherwise disturb your work. The notify option of the set command causes the shell to print these job change messages
*** 2239,2298 **** value of the last command executed. If a command name is not a special built-in command or a user defined function, but it is one of the built-in commands, it is executed in the current shell process. ! The shell variable PATH defines the search path for the directory ! containing the command. Alternative directory names are separated by a ! colon (:). The default path is /bin:/usr/bin:, specifying /bin, ! /usr/bin, and the current directory in that order. The current ! directory can be specified by two or more adjacent colons, or by a ! colon at the beginning or end of the path list. If the command name ! contains a slash (/), the search path is not used. Otherwise, each ! directory in the path is searched for an executable file of the ! specified name that is not a directory. If found, and if the shell ! determines that there is a built-in version of a command corresponding ! to a specified pathname, this built-in is invoked in the current ! process. If found, and this directory is also contained in the value of ! the FPATH variable, then this file is loaded into the current shell environment as if it were the argument to the . command except that only preset aliases are expanded, and a function of the specified name ! is executed as described in this manual page. If not found, and the ! file .paths is found, and this file contains a line of the form ! FPATH=path where path is an existing directory, and this directory ! contains a file of the specified name, then this file is loaded into ! the current shell environment as if it were the argument to the . ! special built-in command and a function of the specified name is ! executed. Otherwise, if found, a process is created and an attempt is ! made to execute the command using exec(2). ! When an executable is found, the directory where it is found in is ! searched for a file named .paths. If this file is found and it contains ! a line of the form BUILTIN_LIB=value, the library named by value is ! searched for as if it were an option argument to builtin -f, and if it ! contains a built-in of the specified name this is executed instead of a ! command by this name. Otherwise, if this file is found and it contains ! a line of the form name=value in the first or second line, then the ! environment variable name is modified by prepending the directory ! specified by value to the directory list. If value is not an absolute ! directory, then it specifies a directory relative to the directory that ! the executable was found. If the environment variable name does not ! already exist it is added to the environment list for the specified ! command. If the file has execute permission but is not an a.out file, it is assumed to be a file containing shell commands. A separate shell is spawned to read it. All non-exported variables are removed in this case. If the shell command file doesn't have read permission, and/or if the setuid and setgid bits are set on the file, then the shell executes an agent whose job it is to set up the permissions and execute the ! shell with the shell command file passed down as an open file. A ! parenthesized command is executed in a sub-shell without removing non- ! exported variables. Command Re-entry The text of the last HISTSIZE (default 512) commands entered from a terminal device is saved in a history file. The file $HOME/.sh_history is used if the HISTFILE variable is not set or if the file it names is not writable. A shell can access the commands of all interactive shells --- 2421,2498 ---- value of the last command executed. If a command name is not a special built-in command or a user defined function, but it is one of the built-in commands, it is executed in the current shell process. ! The shell variables PATH and FPATH define the search path for the ! directory containing the command. Alternative directory names are ! separated by a colon (:). The default path is /bin:/usr/bin:, ! specifying /bin, /usr/bin, and the current directory in that order. The ! current directory can be specified by two or more adjacent colons, or ! by a colon at the beginning or end of the path list. If the command ! name contains a slash (/), the search path is not used. Otherwise, each ! directory in the list of directories defined by PATH and FPATH is ! checked in order. If the directory being searched is contained in the ! value of the FPATH variable and contains a file whose name matches the ! command being searched, then this file is loaded into the current shell environment as if it were the argument to the . command except that only preset aliases are expanded, and a function of the specified name ! is executed as described in this manual page. ! If this directory is not in FPATH, the shell first determines whether ! there is a built-in version of a command corresponding to a given ! pathname and, if so, it is invoked in the current process. If no built- ! in is found, the shell checks for a file named .paths in this ! directory. If found and there is a line of the form: + FPATH=path + where path is an existing directory, then that directory is searched + immediately after the current directory as if it were found in the + FPATH variable. If path does not begin with /, it is checked for + relative to the directory being searched. + + + The .paths file is then checked for a line of the form: + + PLUGIN_LIB=libname [ : libname ] ... + + Each library named by libname will be searched for as if it were an + option argument to builtin -f and, if it contains a built-in of the + specified name, this is executed instead of a command by this name. + + + Any built-in loaded from a library found this way will be associated + with the directory containing the .paths file so it will only execute + if not found in an earlier directory. + + + Finally, the directory will be checked for a file of the given name. If the file has execute permission but is not an a.out file, it is assumed to be a file containing shell commands. A separate shell is spawned to read it. All non-exported variables are removed in this case. If the shell command file doesn't have read permission, and/or if the setuid and setgid bits are set on the file, then the shell executes an agent whose job it is to set up the permissions and execute the ! shell with the shell command file passed down as an open file. + If the .paths contains a line of the form: + + name=value + + in the first or second line, then the environment variable name is + modified by prepending the directory specified by value to the + directory list. If value is not an absolute directory, then it + specifies a directory relative to the directory in which the executable + was found. If the environment variable name does not already exist it + will be added to the environment list for the specified command. + + A parenthesized command is executed in a sub-shell without removing + non-exported variables. + + Command Re-entry The text of the last HISTSIZE (default 512) commands entered from a terminal device is saved in a history file. The file $HOME/.sh_history is used if the HISTFILE variable is not set or if the file it names is not writable. A shell can access the commands of all interactive shells
*** 3240,3250 **** If name is not specified, and no -f option is specified, the built- ins are printed on standard output. The -s option prints only the special built-ins. Otherwise, each name represents the pathname whose basename is the name of the built-in. The entry point ! function name is determined by prepending b to the built-in name. The ISO C/C++ prototype is bmycommand(int argc, char *argv[], void *context) for the built-in command mycommand where argv is an array of argc elements and context is an optional pointer to a Shell_t structure as described in <ast/shell.h> Special built-ins cannot be bound to a pathname or deleted. The -d option deletes each of the --- 3440,3455 ---- If name is not specified, and no -f option is specified, the built- ins are printed on standard output. The -s option prints only the special built-ins. Otherwise, each name represents the pathname whose basename is the name of the built-in. The entry point ! function name is determined by prepending b_ to the built-in name. ! A built-in specified by a pathname will only be executed when that ! pathname would be found during the path search. Built-ins found in ! libraries loaded via the .paths file will be associate with the ! pathname of the directory containing the .paths file. ! The ISO C/C++ prototype is bmycommand(int argc, char *argv[], void *context) for the built-in command mycommand where argv is an array of argc elements and context is an optional pointer to a Shell_t structure as described in <ast/shell.h> Special built-ins cannot be bound to a pathname or deleted. The -d option deletes each of the
*** 3334,3343 **** --- 3539,3558 ---- behavior of echo is system dependent and print or printf described in this section should be used. See echo(1) for usage and description. + ++enum [ -i ] type[=(value ...) ] + + Creates a declaration command named type that is an integer type + that allows one of the specified values as enumeration names. If + =(value ...) is omitted, then type must be an indexed array + variable with at least two elements and the values are taken from + this array variable. If -i is specified the values are case + insensitive. + + +eval [arg ...] The arguments are read as input to the shell and the resulting commands are executed.
*** 3368,3381 **** ++export [-p] [name[=value]] ... If name is not specified, the names and values of each variable with the export attribute are printed with the values quoted in a ! manner that allows them to be re-entered. The -p option causes the ! word export to be inserted before each one. Otherwise, the ! specified names are marked for automatic export to the environment ! of subsequently-executed commands. false Does nothing, and exits 1. Used with until for infinite loops. --- 3583,3598 ---- ++export [-p] [name[=value]] ... If name is not specified, the names and values of each variable with the export attribute are printed with the values quoted in a ! manner that allows them to be re-entered. The export command is the ! same as typeset -x except that if you use export within a function, ! no local variable is created. The -p option causes the word export ! to be inserted before each one. Otherwise, the specified names are ! marked for automatic export to the environment of subsequently- ! executed commands. false Does nothing, and exits 1. Used with until for infinite loops.
*** 3462,3472 **** format of job. kill [-s signame] job ... kill [-n signum] job ... ! kill -l [sig ...] Sends either the TERM (terminate) signal or the specified signal to the specified jobs or processes. Signals are either specified by number with the -n option or by name with the -s option (as specified in <signal.h>, stripped of the prefix `SIG with the --- 3679,3689 ---- format of job. kill [-s signame] job ... kill [-n signum] job ... ! kill -Ll [sig ...] Sends either the TERM (terminate) signal or the specified signal to the specified jobs or processes. Signals are either specified by number with the -n option or by name with the -s option (as specified in <signal.h>, stripped of the prefix `SIG with the
*** 3475,3505 **** immediately after the -. If the signal being sent is TERM (terminate) or HUP (hang up), then the job or process is sent a CONT (continue) signal if it is stopped. The argument job can be the process id of a process that is not a member of one of the active jobs. See Jobs for a description of the format of job. In ! the third form, kill -l, if sig is not specified, the signal names ! are listed. Otherwise, for each sig that is a name, the ! corresponding signal number is listed. For each sig that is a ! number, the signal name corresponding to the least significant 8 ! bits of sig is listed. let [arg ...] ! Each arg is a separate arithmetic expression to be evaluated. See ! the Arithmetic Evaluation section of this manual page for a ! description of arithmetic expression evaluation. The exit status is ! 0 if the value of the last expression is non-zero, and 1 otherwise. +newgrp [arg ...] Equivalent to exec /bin/newgrp arg ... ! print [-Renprs] [ -u unit] [ -f format ] [ arg ...] With no options or with option - or --, each arg is printed on standard output. The -f option causes the arguments to be printed as described by printf. In this case, any e, n, r, or R options are ignored. Otherwise, unless the -R or -r, are specified, the --- 3692,3725 ---- immediately after the -. If the signal being sent is TERM (terminate) or HUP (hang up), then the job or process is sent a CONT (continue) signal if it is stopped. The argument job can be the process id of a process that is not a member of one of the active jobs. See Jobs for a description of the format of job. In ! the third form, kill -l or kill -L, if sig is not specified, the ! signal names are listed. The -l option lists only the signal names ! whereas -L lists each signal name and corresponding number. ! Otherwise, for each sig that is a name, the corresponding signal ! number is listed. For each sig that is a number, the signal name ! corresponding to the least significant 8 bits of sig is listed. let [arg ...] ! Each arg is a separate arithmetic expression to be evaluated. let ! only recognizes octal constants starting with 0 when the set option ! letoctal is on. See the Arithmetic Evaluation section of this ! manual page for a description of arithmetic expression evaluation. ! The exit status is 0 if the value of the last expression is non- ! zero, and 1 otherwise. +newgrp [arg ...] Equivalent to exec /bin/newgrp arg ... ! print [-CRenprsv] [ -u unit] [ -f format ] [ arg ...] With no options or with option - or --, each arg is printed on standard output. The -f option causes the arguments to be printed as described by printf. In this case, any e, n, r, or R options are ignored. Otherwise, unless the -R or -r, are specified, the
*** 3552,3613 **** The -R option prints all subsequent arguments and options other than -n. The -e causes the escape conventions to be applied This is the default behavior. It reverses the effect of an earlier -r. The -p option causes the arguments to be written onto the pipe of the ! process spawned with |& instead of standard output. The -s option causes the arguments to be written onto the history file instead of standard output. The -u option can be used to specify a one digit file descriptor unit number unit on which the output is placed. The default is 1. If the option -n is used, no NEWLINE is added to the output. ! printf format[arg ...] The arguments arg are printed on standard output in accordance with the ANSI-C formatting rules associated with the format string format. If the number of arguments exceeds the number of format specifications, the format string is reused to format remaining ! arguments. The following extensions can also be used: A %b format ! can be used instead of %s to cause escape sequences in the ! corresponding arg to be expanded as described in print. A %B option ! causes each of the arguments to be treated as variable names and ! the binary value of the variables is printed. This is most useful ! for variables with an attribute of b. A %H format can be used ! instead of %s to cause characters in arg that are special in HTML ! and XML to be output as their entity name. A %P format can be used ! instead of %s to cause arg to be interpreted as an extended regular ! expression and be printed as a shell pattern. A %R format can be ! used instead of %s to cause arg to be interpreted as a shell ! pattern and to be printed as an extended regular expression. A %q ! format can be used instead of %s to cause the resulting string to ! be quoted in a manner than can be input again to the shell. A ! %(date-format)T format can be use to treat an argument as a ! date/time string and to format the date/time according to the date- ! format as defined for the date(1) command. A %Z format outputs a ! byte whose value is 0. The precision field of the %d format can be ! followed by a . and the output base. In this case, the # flag ! character causes base# to be prepended. The # flag when used with ! the d specifier without an output base, causes the output to be ! displayed in thousands units with one of the suffixes k M G T P E ! to indicate the unit. The # flag when used with the i specifier ! causes the output to be displayed in 1024 with one of the suffixes ! Ki Mi Gi Ti Pi Ei to indicate the unit. The = flag has been added ! to center the output within the specified field width. pwd [-LP] Outputs the value of the current working directory. The -L option is the default. It prints the logical name of the current directory. If the -P option is specified, all symbolic links are resolved from the name. The last instance of -L or -P on the command line determines which method is used. ! read [-Aprs] [-d delim] [ -n n] [[ -N n] [[-t timeout] [-u unit] [vname?prompt] [ vname ... ] The shell input mechanism. One line is read and is broken up into fields using the characters in IFS as separators. The escape character, \, is used to remove any special meaning for the next --- 3772,3907 ---- The -R option prints all subsequent arguments and options other than -n. The -e causes the escape conventions to be applied This is the default behavior. It reverses the effect of an earlier -r. The -p option causes the arguments to be written onto the pipe of the ! process spawned with |& instead of standard output. The -v option ! treats each arg as a variable name and writes the value in the ! printf %B format. The -C option treats each arg as a variable name ! and writes the values in the printf %#B format. The -s option causes the arguments to be written onto the history file instead of standard output. The -u option can be used to specify a one digit file descriptor unit number unit on which the output is placed. The default is 1. If the option -n is used, no NEWLINE is added to the output. ! printf format [arg ...] The arguments arg are printed on standard output in accordance with the ANSI-C formatting rules associated with the format string format. If the number of arguments exceeds the number of format specifications, the format string is reused to format remaining ! arguments. The following extensions can also be used: + %b + + A %b format can be used instead of %s to cause escape sequences + in the corresponding arg to be expanded as described in print. + + + %B + + A %B option causes each of the arguments to be treated as + variable names and the binary value of the variables is + printed. This is most useful for variables with an attribute of + b. + + + %H + + A %H format can be used instead of %s to cause characters in + arg that are special in HTML and XML to be output as their + entity name. The alternate flag # formats the output for use as + a URI. + + + %P + + A %P format can be used instead of %s to cause arg to be + interpreted as an extended regular expression and be printed as + a shell pattern. + + + + %R + + A %R format can be used instead of %s to cause arg to be + interpreted as a shell pattern and to be printed as an extended + regular expression. + + + %q + + A %q format can be used instead of %s to cause the resulting + string to be quoted in a manner than can be input again to the + shell. When q is preceded by the alternative format specifier, + #, the string is quoted in manner suitable as a field in a .csv + format file. + + + %(date-format) + + A %(date-format)T format can be use to treat an argument as a + date/time string and to format the date/time according to the + date-format as defined for the date(1) command. + + + + %Z + + A %Z format outputs a byte whose value is 0. + + + %d + + The precision field of the %d format can be followed by a . and + the output base. In this case, the # flag character causes + base# to be prepended. + + + # + + The # flag, when used with the %d format without an output + base, displays the output in powers of 1000 indicated by one of + the following suffixes: k M G T P E, and when used with the %i + format displays the output in powers of 1024 indicated by one + of the following suffixes: Ki Mi Gi Ti Pi Ei. + + + + = + + The = flag centers the output within the specified field width. + + + L + + The L flag, when used with the %c or %s formats, treats + precision as character width instead of byte count. + + + , + + The , flag, when used with the %d or %f formats, separates + groups of digits with the grouping delimiter (, in groups of 3 + in the C locale). + + + + pwd [-LP] Outputs the value of the current working directory. The -L option is the default. It prints the logical name of the current directory. If the -P option is specified, all symbolic links are resolved from the name. The last instance of -L or -P on the command line determines which method is used. ! read [-ACSprsv] [-d delim] [ -n n] [[ -N n] [[-t timeout] [-u unit] [vname?prompt] [ vname ... ] The shell input mechanism. One line is read and is broken up into fields using the characters in IFS as separators. The escape character, \, is used to remove any special meaning for the next
*** 3624,3647 **** -n or -N is specified, the bytes that are read are stored directly into the variable. If the -v is specified, then the value of the first vname is used as a default value when reading from a terminal device. The -A option causes the variable vname to be unset and each field that is read to be stored in successive elements of the ! indexed array vname. The -p option causes the input line to be ! taken from the input pipe of a process spawned by the shell using ! |&. If the -s option is present, the input is saved as a command in ! the history file. The option -u can be used to specify a one digit ! file descriptor unit unit to read from. The file descriptor can be ! opened with the exec special built-in command. The default value of ! unit n is 0. The option -t is used to specify a time out in seconds ! when reading from a terminal or pipe. If vname is omitted, then ! REPLY is used as the default vname. An end-of-file with the -p ! option causes cleanup for this process so that another can be ! spawned. If the first argument contains a ?, the remainder of this ! word is used as a prompt on standard error when the shell is ! interactive. The exit status is 0 unless an end-of-file is ! encountered or read has timed out. ++readonly [-p] [ vname[=value]] ... If vname is not specified, the names and values of each variable --- 3918,3946 ---- -n or -N is specified, the bytes that are read are stored directly into the variable. If the -v is specified, then the value of the first vname is used as a default value when reading from a terminal device. The -A option causes the variable vname to be unset and each field that is read to be stored in successive elements of the ! indexed array vname. The -C option causes the variable vname to be ! read as a compound variable. Blanks will be ignored when finding ! the beginning open parenthesis. The -S option causes the line to be ! treated like a record in a .csv format file so that double quotes ! can be used to allow the delimiter character and the new-line ! character to appear within a field. The -p option causes the input ! line to be taken from the input pipe of a process spawned by the ! shell using |&. If the -s option is present, the input is saved as ! a command in the history file. The option -u can be used to specify ! a one digit file descriptor unit unit to read from. The file ! descriptor can be opened with the exec special built-in command. ! The default value of unit n is 0. The option -t is used to specify ! a time out in seconds when reading from a terminal or pipe. If ! vname is omitted, then REPLY is used as the default vname. An end- ! of-file with the -p option causes cleanup for this process so that ! another can be spawned. If the first argument contains a ?, the ! remainder of this word is used as a prompt on standard error when ! the shell is interactive. The exit status is 0 unless an end-of- ! file is encountered or read has timed out. ++readonly [-p] [ vname[=value]] ... If vname is not specified, the names and values of each variable
*** 3699,3710 **** to truncate a file when turned on. -e ! If a command has a non-zero exit status, execute the ERR trap, ! if set, and exit. This mode is disabled while reading profiles. -f Disables file name generation. --- 3998,4012 ---- to truncate a file when turned on. -e ! Unless contained in a || or && command, or the command ! following an if, while or until command or in the pipeline ! following !, if a command has a non-zero exit status, execute ! the ERR trap, if set, and exit. This mode is disabled while ! reading profiles. -f Disables file name generation.
*** 3800,3809 **** --- 4102,4116 ---- keyword Same as -k. + letoctal + + The let command allows octal constants starting with 0. + + markdirs All directory names resulting from file name generation have a trailing / appended.
*** 4001,4011 **** true Does nothing, and exits 0. Used with while for infinite loops. ! ++typeset [+-AHflabnprtux ] [ +-EFLRZi[n] ] [ vname[=value ] ] Sets attributes and values for shell variables and functions. When invoked inside a function defined with the function name syntax, a new instance of the variable vname is created, and the variable's value and type are restored when the function completes. --- 4308,4319 ---- true Does nothing, and exits 0. Used with while for infinite loops. ! ++typeset [+-ACHSfblmnprtux ] [ +-EFLRXZi[n] ] [ +-M [ mapname ] ] [ -T ! [ tname=(assign_list) ] ] [ -h str ] [ -a [type] ] [ vname[=value ] ] Sets attributes and values for shell variables and functions. When invoked inside a function defined with the function name syntax, a new instance of the variable vname is created, and the variable's value and type are restored when the function completes.
*** 4042,4051 **** --- 4350,4365 ---- bytes whose value is zero. The printf format %B can be used to output the actual data in this buffer instead of the base64 encoding of the data. + -C + Causes each vname to be a compound variable. If value names a + compound variable it is copied into vname. Otherwise, it + unsets each vname. + + -E Declares vname to be a double precision floating point number. If n is non-zero, it defines the number of significant figures that are used when expanding vname. Otherwise, ten significant figures is used.
*** 4061,4071 **** options other than -f is specified, then the function definition is displayed on standard output. If +f is specified, then a line containing the function name followed by a shell comment containing the line number and path name of the file where this function was defined, if any, is ! displayed. The -i attribute cannot be specified with -f. -F --- 4375,4406 ---- options other than -f is specified, then the function definition is displayed on standard output. If +f is specified, then a line containing the function name followed by a shell comment containing the line number and path name of the file where this function was defined, if any, is ! displayed. The names refer to function names rather than ! variable names. No assignments can be made and the only ! other valid options are -S, -t, -u and -x. The -S can be ! used with discipline functions defined in a type to indicate ! that the function is static. For a static function, the same ! method will be used by all instances of that type no matter ! which instance references it. In addition, it can only use ! value of variables from the original type definition. These ! discipline functions cannot be redefined in any type ! instance. The -t option turns on execution tracing for this ! function. The -u option causes this function to be marked ! undefined. The FPATH variable will be searched to find the ! function definition when the function is referenced. If no ! options other than -f is specified, then the function ! definition will be displayed on standard output. If +f is ! specified, then a line containing the function name followed ! by a shell comment containing the line number and path name ! of the file where this function was defined, if any, is ! displayed. The exit status can be used to determine whether ! the function is defined so that typeset -f .sh.math. name ! will return 0 when math function name is defined and non-zero ! otherwise. The -i attribute cannot be specified with -f. -F
*** 4073,4082 **** --- 4408,4425 ---- number. If n is non-zero, it defines the number of places after the decimal point that are used when expanding vname. Otherwise ten places after the decimal point is used. + -h + Used within type definitions to add information when + generating information about the sub-variable on the man + page. It is ignored when used outside of a type definition. + When used with -f the information is associated with the + corresponding discipline function. + + -H This option provides UNIX to hostname file mapping on non- UNIX machines.
*** 4090,4101 **** The -i attribute cannot be specified along with -R, -L, -Z, or -f. -l ! All uppercase characters are converted to lowercase. The ! uppercase option, -u, is turned off. -L Left justify and remove leading blanks from value. If n is non-zero, it defines the width of the field, otherwise it is --- 4433,4446 ---- The -i attribute cannot be specified along with -R, -L, -Z, or -f. -l ! Used with -i, -E or -F to indicate long integer, or long ! float. Otherwise, all upper-case characters are converted to ! lower-case. The upper-case option, -u, is turned off. ! Equivalent to -M tolower. -L Left justify and remove leading blanks from value. If n is non-zero, it defines the width of the field, otherwise it is
*** 4105,4121 **** --- 4450,4489 ---- field. The -R option is turned off. The -i attribute cannot be specified with -L. + -m + moves or renames the variable. The value is the name of a + variable whose value will be moved to vname. The original + variable will be unset. Cannot be used with any other + options. + + + -M + Use the character mapping mapping such as tolower and toupper + when assigning a value to each of the specified operands. + When mapping is specified and there are not operands, all + variables that use this mapping are written to standard + output. When mapping is omitted and there are no operands, + all mapped variables are written to standard output. + + -n Declares vname to be a reference to the variable whose name is defined by the value of variable vname. This is usually used to reference a variable inside a function whose name has been passed as an argument. + -p + The name, attributes and values for the given vname are + written on standard output in a form that can be used as + shell input. If +p is specified, then the values are not + displayed. + + -R Right justify and fill with leading blanks. If n is non-zero, it defines the width of the field, otherwise it is determined by the width of the value of first assignment. The field is left filled with blanks or truncated from the end if the
*** 4127,4152 **** -r The specified vnames are marked read-only and these names cannot be changed by subsequent assignment. -t Tags the variables. Tags are user definable and have no special meaning to the shell. -u ! All lowercase characters are converted to uppercase. The ! lowercase option, -l, is turned off. -x The specified vnames are marked for automatic export to the environment of subsequently-executed commands. Variables whose names contain a . cannot be exported. -Z Right justify and fill with leading zeros if the first non- blank character is a digit and the -L option has not been set. Remove leading zeros if the -L option is also set. If n is non-zero, it defines the width of the field, otherwise it --- 4495,4544 ---- -r The specified vnames are marked read-only and these names cannot be changed by subsequent assignment. + -S + When used within the assign_list of a type definition, it + causes the specified sub-variable to be shared by all + instances of the type. When used inside a function defined + with the function reserved word, the specified variables will + have function static scope. Otherwise, the variable is unset + prior to processing the assignment list. + + -t Tags the variables. Tags are user definable and have no special meaning to the shell. + -T + If followed by tname, it creates a type named by tname using + the compound assignment assign_list to tname. Otherwise, it + writes all the type definitions to standard output. + + -u ! When given along with -i specifies unsigned integer. ! Otherwise, all lower-case characters are converted to upper- ! case. The lower-case option, -l, is turned off. Equivalent ! to -M toupper. -x The specified vnames are marked for automatic export to the environment of subsequently-executed commands. Variables whose names contain a . cannot be exported. + -X + Declares vname to be a double precision floating point number + and expands using the %a format of ISO-C99. If n is non- + zero, it defines the number of hex digits after the radix + point that is used when expanding vname. The default is 10. + + -Z Right justify and fill with leading zeros if the first non- blank character is a digit and the -L option has not been set. Remove leading zeros if the -L option is also set. If n is non-zero, it defines the width of the field, otherwise it
*** 4320,4329 **** --- 4712,4726 ---- This set of strings is subject to language translation when the locale is not C or POSIX. No commands are executed. + -E + Reads the file named by the ENV variable or by + $HOME/.kshrc if not defined after the profiles. + + -i If the -i option is present or if the shell input and output are attached to a terminal (as told by tcgetattr(3C), this shell is interactive. In this case TERM is ignored (so that kill 0 does not kill an
*** 4330,4339 **** --- 4727,4741 ---- interactive shell) and INTR is caught and ignored (so that wait is interruptible). In all cases, QUIT is ignored by the shell. + -P + If -P or -o profile is present, the shell is a profile + shell (see pfexec(1)). + + -R filename The -R filename option is used to generate a cross reference database that can be used by a separate utility to find definitions and references for variables and commands.
*** 4480,4494 **** The scripting interface is Uncommitted. The environment variables, .paths feature, and editing modes are Volatile. SEE ALSO cat(1), cd(1), chmod(1), cut(1), date(1), egrep(1), echo(1), egrep(1), ! env(1), fgrep(1), grep(1), login(1), newgrp(1), paste(1), printf(1), ! stty(1), test(1), umask(1), vi(1), dup(2), exec(2), fork(2), ioctl(2), ! lseek(2), pathconf(2), pipe(2), sysconf(3C), ulimit(2), umask(2), ! rand(3C), tcgetattr(3C), wait(3C), a.out(4), profile(4), attributes(5), ! environ(5), largefile(5), standards(5) Bolsky, Morris I. and Korn, David G., The New KornShell Command and Programming Language, Prentice Hall, 1995. --- 4882,4896 ---- The scripting interface is Uncommitted. The environment variables, .paths feature, and editing modes are Volatile. SEE ALSO cat(1), cd(1), chmod(1), cut(1), date(1), egrep(1), echo(1), egrep(1), ! env(1), fgrep(1), grep(1), login(1), newgrp(1), paste(1), pfexec(1), ! printf(1), stty(1), test(1), umask(1), vi(1), dup(2), exec(2), fork(2), ! ioctl(2), lseek(2), pathconf(2), pipe(2), sysconf(3C), ulimit(2), ! umask(2), rand(3C), tcgetattr(3C), wait(3C), a.out(4), profile(4), ! attributes(5), environ(5), largefile(5), standards(5) Bolsky, Morris I. and Korn, David G., The New KornShell Command and Programming Language, Prentice Hall, 1995.
*** 4539,4544 **** If the system supports the 64-bit instruction set, /bin/ksh93 executes the 64-bit version of ksh93. ! June 27, 2018 KSH93(1) --- 4941,4946 ---- If the system supports the 64-bit instruction set, /bin/ksh93 executes the 64-bit version of ksh93. ! January 6, 2020 KSH93(1)