1*b4dd7d09SAndy FiddamanThis is a list of changes that have been made since the 11/16/88 version 2*b4dd7d09SAndy Fiddamanof ksh. 3*b4dd7d09SAndy Fiddaman 4*b4dd7d09SAndy Fiddaman1. New features in 12/28/93 5*b4dd7d09SAndy Fiddaman a. Associative arrays. The new version of ksh supports both 6*b4dd7d09SAndy Fiddaman associate arrays and the older indexed arrays with the same 7*b4dd7d09SAndy Fiddaman array syntax. A new -A option of typeset is used to declare 8*b4dd7d09SAndy Fiddaman an array to be associative. As with indexed arrays, $name is 9*b4dd7d09SAndy Fiddaman equivalent to ${name[0]}. The prefix operator ! was added 10*b4dd7d09SAndy Fiddaman to the parameter expansion syntax to expand to the list of 11*b4dd7d09SAndy Fiddaman indices. For example, ${!name[@]} expands to the list of array 12*b4dd7d09SAndy Fiddaman indices for variable name. 13*b4dd7d09SAndy Fiddaman 14*b4dd7d09SAndy Fiddaman b. Several additions have been made to shell arithmetic: 15*b4dd7d09SAndy Fiddaman 1. The shell now performs floating point arithmetic. The 16*b4dd7d09SAndy Fiddaman typeset options -F and -E have been added for floating 17*b4dd7d09SAndy Fiddaman point and scientific notation respectively. 18*b4dd7d09SAndy Fiddaman 2. The prefix and postfix ++ and -- operators. 19*b4dd7d09SAndy Fiddaman 3. The comma and ?: operators. 20*b4dd7d09SAndy Fiddaman 4. The math library functions. 21*b4dd7d09SAndy Fiddaman 5. An arithmetic for statement of the form 22*b4dd7d09SAndy Fiddaman for ((expr1; expr2; expr3)) 23*b4dd7d09SAndy Fiddaman do ... 24*b4dd7d09SAndy Fiddaman done 25*b4dd7d09SAndy Fiddaman 6. Integer arithmetic extended up to base 64. 26*b4dd7d09SAndy Fiddaman 27*b4dd7d09SAndy Fiddaman c. Some additions to the macro expansion syntax have been made 28*b4dd7d09SAndy Fiddaman to specify substrings and sub-arrays: 29*b4dd7d09SAndy Fiddaman 1. ${name:expr} expands to the substring of ${name} starting at 30*b4dd7d09SAndy Fiddaman the character position defined by arithmetic expression expr. 31*b4dd7d09SAndy Fiddaman 2. ${name:expr1:expr2} expands to the substring of ${name} starting 32*b4dd7d09SAndy Fiddaman at expr1 and consisting of at most expr2 characters. 33*b4dd7d09SAndy Fiddaman 3. ${name[@]:expr} expands to the values of ${name[@]} starting at 34*b4dd7d09SAndy Fiddaman the element defined by arithmetic expression expr. 35*b4dd7d09SAndy Fiddaman 4. ${name[@]:expr1:expr2} expands to at most expr2 values of 36*b4dd7d09SAndy Fiddaman ${name} starting at expr1. 37*b4dd7d09SAndy Fiddaman 5. ${@:expr} expands the positional parameters starting at expr. 38*b4dd7d09SAndy Fiddaman 6. ${@:expr1:expr2} expands to at most expr2 positional parameters 39*b4dd7d09SAndy Fiddaman starting at expr1. 40*b4dd7d09SAndy Fiddaman 7. ${!name} expands to the name of the variable named by name. 41*b4dd7d09SAndy Fiddaman It will expand to name unless name is reference variable. 42*b4dd7d09SAndy Fiddaman 8. ${!name[sub]} expands to the name of the subscript of the 43*b4dd7d09SAndy Fiddaman given variable. If sub is @ or * the list of subscripts 44*b4dd7d09SAndy Fiddaman is generated. 45*b4dd7d09SAndy Fiddaman 9. ${!prefix*} and ${!prefix@} expand to the list of variable 46*b4dd7d09SAndy Fiddaman names beginning with prefix. 47*b4dd7d09SAndy Fiddaman 10. The substring operators, # and % can be now be applied 48*b4dd7d09SAndy Fiddaman with aggregates (@ or *) and are applied to each. 49*b4dd7d09SAndy Fiddaman 11. ${name/pattern/string} expands to the value of name with 50*b4dd7d09SAndy Fiddaman the first occurrence of pattern replaced by string. 51*b4dd7d09SAndy Fiddaman With aggregates (@ or *) this operation is applied to each. 52*b4dd7d09SAndy Fiddaman 12. ${name/#pattern/string} Same as above but the pattern 53*b4dd7d09SAndy Fiddaman to be replaced must match at the beginning. 54*b4dd7d09SAndy Fiddaman 13. ${name/%pattern/string} Same as above but the pattern 55*b4dd7d09SAndy Fiddaman to be replaced must match at the end. 56*b4dd7d09SAndy Fiddaman 14. ${name//pattern/string} expands to the value of name with 57*b4dd7d09SAndy Fiddaman the each occurrence of pattern replaced by string. 58*b4dd7d09SAndy Fiddaman With aggregates (@ or *) this operation is applied to each. 59*b4dd7d09SAndy Fiddaman 60*b4dd7d09SAndy Fiddaman d. The name space for variables has been extended. The character '.' 61*b4dd7d09SAndy Fiddaman can be used at the beginning of a name, and to separate identifiers 62*b4dd7d09SAndy Fiddaman within a name. However, to create a name of the form, foo.bar, 63*b4dd7d09SAndy Fiddaman the variable foo must exist. The namespace starting with .sh 64*b4dd7d09SAndy Fiddaman is reserved for shell implementation variables. Exported 65*b4dd7d09SAndy Fiddaman variable cannot contain a '.'. 66*b4dd7d09SAndy Fiddaman 67*b4dd7d09SAndy Fiddaman e. Compound assignments. The assignment syntax, varname=value, 68*b4dd7d09SAndy Fiddaman has been extended to allow assignments of the form 69*b4dd7d09SAndy Fiddaman varname=(assignment_list). As elsewhere in the shell 70*b4dd7d09SAndy Fiddaman spaces or tabs are optional around the parentheses, and 71*b4dd7d09SAndy Fiddaman no space is permitted between the varname and the =. The 72*b4dd7d09SAndy Fiddaman assignment_list can be one of the following: 73*b4dd7d09SAndy Fiddaman 1. A list of words. In this case each word is expanded as 74*b4dd7d09SAndy Fiddaman in a for list and the resulting items become elements 75*b4dd7d09SAndy Fiddaman of the indexed array varname. 76*b4dd7d09SAndy Fiddaman 2. A list of subscript assignments in the form 77*b4dd7d09SAndy Fiddaman [subscript]=value. In this, these elements become 78*b4dd7d09SAndy Fiddaman elements of the associative array varname. 79*b4dd7d09SAndy Fiddaman 3. A list of assignments; simple or compound. In this 80*b4dd7d09SAndy Fiddaman case, each assignment is made to varname.name, where 81*b4dd7d09SAndy Fiddaman name is the name of the enclosed assignment. 82*b4dd7d09SAndy Fiddaman 4. Assignments in the form of readonly or typeset 83*b4dd7d09SAndy Fiddaman statements. In this case each assignment is made as 84*b4dd7d09SAndy Fiddaman in 3 above, and the attributes are given to the 85*b4dd7d09SAndy Fiddaman corresponding variable. 86*b4dd7d09SAndy Fiddaman In case 3 and 4 above, the value of "$varname" after 87*b4dd7d09SAndy Fiddaman the above assignment is (assignment_list), where the 88*b4dd7d09SAndy Fiddaman assignment_list produced would reproduce all of the 89*b4dd7d09SAndy Fiddaman variables under varname.*. 90*b4dd7d09SAndy Fiddaman 91*b4dd7d09SAndy Fiddaman f. Function names of the form variable.action (called discipline 92*b4dd7d09SAndy Fiddaman functions) can be defined where variable is any valid variable 93*b4dd7d09SAndy Fiddaman name and action is get, set, or unset. The function variable.get 94*b4dd7d09SAndy Fiddaman is invoked each time the variable is referenced. The set 95*b4dd7d09SAndy Fiddaman discipline is invoked each time the variable is assigned to. 96*b4dd7d09SAndy Fiddaman The unset discipline is invoked when a variable is unset. 97*b4dd7d09SAndy Fiddaman The new variables .sh.name, .sh.subscript, and .sh.value are 98*b4dd7d09SAndy Fiddaman defined inside the function body. Other shell extensions 99*b4dd7d09SAndy Fiddaman may have their own set of discipline functions. 100*b4dd7d09SAndy Fiddaman 101*b4dd7d09SAndy Fiddaman g. The compound command !, which negates the return value of the 102*b4dd7d09SAndy Fiddaman following pipeline, has been added. 103*b4dd7d09SAndy Fiddaman 104*b4dd7d09SAndy Fiddaman h. On systems that support dynamic loading with dlopen(), it is 105*b4dd7d09SAndy Fiddaman now possible to add built-in commands at runtime with the 106*b4dd7d09SAndy Fiddaman a builtin command named builtin. 107*b4dd7d09SAndy Fiddaman 108*b4dd7d09SAndy Fiddaman i. The following builtins have been added: 109*b4dd7d09SAndy Fiddaman 1. command name [ ... ] 110*b4dd7d09SAndy Fiddaman 2. sleep [decimal-seconds] 111*b4dd7d09SAndy Fiddaman 3. builtin [-ds] [-f file] [name...] 112*b4dd7d09SAndy Fiddaman 4. getconf name [pathname] 113*b4dd7d09SAndy Fiddaman 5. disown [job...] 114*b4dd7d09SAndy Fiddaman 115*b4dd7d09SAndy Fiddaman j. An addition format for literal strings, $'....' can 116*b4dd7d09SAndy Fiddaman be used where ever literal strings are valid. The string 117*b4dd7d09SAndy Fiddaman inside the single quotes will be converted using the ANSI-C 118*b4dd7d09SAndy Fiddaman escape conventions. Additionally, the escape sequence \E 119*b4dd7d09SAndy Fiddaman expands to the escape character (default \033) whenever ANSI-C 120*b4dd7d09SAndy Fiddaman escape sequences are recognized. 121*b4dd7d09SAndy Fiddaman 122*b4dd7d09SAndy Fiddaman k. A typeset -n option has been added which causes the value of a 123*b4dd7d09SAndy Fiddaman variable to be treated as a reference to another variable so that 124*b4dd7d09SAndy Fiddaman variables can be indirectly named. For example, if $1 contains 125*b4dd7d09SAndy Fiddaman the name of a variable, then typeset -n foo=$1 causes the variable 126*b4dd7d09SAndy Fiddaman foo to be synonymous with the variable whose name is $1. A builtin 127*b4dd7d09SAndy Fiddaman alias, nameref='typeset -n' has been added to aid mnemonics. 128*b4dd7d09SAndy Fiddaman Reference names cannot contain a '.'. Whenever that portion of 129*b4dd7d09SAndy Fiddaman a variable up to the first '.' matches a reference name, the 130*b4dd7d09SAndy Fiddaman reference value is substituted. For example, with nameref foo=.top, 131*b4dd7d09SAndy Fiddaman then ${foo.bar} is equivalent to ${.top.bar}. When used as the 132*b4dd7d09SAndy Fiddaman index of a for or select loop, each assignment causes a 133*b4dd7d09SAndy Fiddaman new name reference to occur. 134*b4dd7d09SAndy Fiddaman 135*b4dd7d09SAndy Fiddaman l. The KEYBD trap has been added which is triggered when a key 136*b4dd7d09SAndy Fiddaman or escape sequence is typed while reading from the keyboard 137*b4dd7d09SAndy Fiddaman in an edit mode. This, combined with some new variables 138*b4dd7d09SAndy Fiddaman makes it possible to program your key bindings in ksh. 139*b4dd7d09SAndy Fiddaman 140*b4dd7d09SAndy Fiddaman m. New variables have been added: 141*b4dd7d09SAndy Fiddaman 1. FIGNORE defines a set of file names to be ignored in each 142*b4dd7d09SAndy Fiddaman directory when performing pathname expansion, replacing 143*b4dd7d09SAndy Fiddaman the rule that requires that a leading . be matched explicitly. 144*b4dd7d09SAndy Fiddaman 2. Variable sh.edchar contains the value of the keyboard character 145*b4dd7d09SAndy Fiddaman that has been entered when processing a KEYBD trap. If the value 146*b4dd7d09SAndy Fiddaman is changed as part of the trap action, then the new value replaces 147*b4dd7d09SAndy Fiddaman the key or keys that caused the trap. 148*b4dd7d09SAndy Fiddaman 3. Variable sh.edcol is set to the character position of the cursor 149*b4dd7d09SAndy Fiddaman within the input buffer during a KEYBD trap. 150*b4dd7d09SAndy Fiddaman 4. Variable sh.edmode is set to the escape character when in vi 151*b4dd7d09SAndy Fiddaman insert mode. 152*b4dd7d09SAndy Fiddaman 5. Variable sh.edtext is set to the contents of the input buffer 153*b4dd7d09SAndy Fiddaman during a KEYBD trap. 154*b4dd7d09SAndy Fiddaman 6. HISTEDIT is checked before FCEDIT. FCEDIT is obsolete. 155*b4dd7d09SAndy Fiddaman 7. HISTCMD is the number of the current command in the history 156*b4dd7d09SAndy Fiddaman file. 157*b4dd7d09SAndy Fiddaman 8. Variable .sh.version is set to the version string for 158*b4dd7d09SAndy Fiddaman this shell. 159*b4dd7d09SAndy Fiddaman 9. Variable .sh.name is set to the name of the variable 160*b4dd7d09SAndy Fiddaman that that was referenced or assigned to when executing a get 161*b4dd7d09SAndy Fiddaman or set discipline function. 162*b4dd7d09SAndy Fiddaman 10. Variable .sh.subscript is set to the subscript for the variable 163*b4dd7d09SAndy Fiddaman that was referenced or assign to when executing a get or 164*b4dd7d09SAndy Fiddaman set discipline function. 165*b4dd7d09SAndy Fiddaman 11. Variable .sh.value is set to the new value for the variable 166*b4dd7d09SAndy Fiddaman that was assigned to when executing the set discipline function. 167*b4dd7d09SAndy Fiddaman 168*b4dd7d09SAndy Fiddaman n. New invocation and set -o options have been added: 169*b4dd7d09SAndy Fiddaman 1. set -o notify (or set -b) causes background completion messages 170*b4dd7d09SAndy Fiddaman to be displayed as soon as the job completes. 171*b4dd7d09SAndy Fiddaman 2. There is a compile time option named KIA which enables 172*b4dd7d09SAndy Fiddaman creation of a relational database for commands, variables 173*b4dd7d09SAndy Fiddaman and functions defined and referenced by a script. The 174*b4dd7d09SAndy Fiddaman option -I <filename>, causes the database to be generated 175*b4dd7d09SAndy Fiddaman in <filename>. The database format can be queried via 176*b4dd7d09SAndy Fiddaman the cql command. 177*b4dd7d09SAndy Fiddaman o. ksh93 can read and evaluate pre-compiled scripts generated by 178*b4dd7d09SAndy Fiddaman a separate program called shcomp. 179*b4dd7d09SAndy Fiddaman p. More work on internationalization has been added: 180*b4dd7d09SAndy Fiddaman 1. The decimal point character is processed per locale 181*b4dd7d09SAndy Fiddaman 2. A $ can be placed in front of each string to indicate 182*b4dd7d09SAndy Fiddaman that the string needs translation but is otherwise ignored. 183*b4dd7d09SAndy Fiddaman This means that if a message catalog of all $"..." strings 184*b4dd7d09SAndy Fiddaman is generated, then a program such as print $"hello world" 185*b4dd7d09SAndy Fiddaman could display "bonjour monde" in the french locale. 186*b4dd7d09SAndy Fiddaman q. Backreferences have been added to pattern matching. The sequence 187*b4dd7d09SAndy Fiddaman \d, where d is a digit from 1-9, matches the same string as 188*b4dd7d09SAndy Fiddaman the d-th previous parenthesis group. Backreferences 189*b4dd7d09SAndy Fiddaman can be used within patterns, and within replacement strings 190*b4dd7d09SAndy Fiddaman with any of the ${name/...} operators. 191*b4dd7d09SAndy Fiddaman 192*b4dd7d09SAndy Fiddaman2. Changes made in 12/28/93 193*b4dd7d09SAndy Fiddaman a. The output format of many commands has changed as follows: 194*b4dd7d09SAndy Fiddaman 1. System error messages are displayed whenever a failure 195*b4dd7d09SAndy Fiddaman is caused by a system call. 196*b4dd7d09SAndy Fiddaman 2. The exit status has changed in many cases: 197*b4dd7d09SAndy Fiddaman a. USAGE messages cause an exit status of 2. 198*b4dd7d09SAndy Fiddaman b. Commands not found cause exit - 127. 199*b4dd7d09SAndy Fiddaman c. Command found, but not executable - 126. 200*b4dd7d09SAndy Fiddaman d. Terminated because of signal - 256+sig 201*b4dd7d09SAndy Fiddaman 3. The output of values from built-ins that contain special 202*b4dd7d09SAndy Fiddaman characters are quoted in a manner that then can be re-input. 203*b4dd7d09SAndy Fiddaman 4. The trace output puts quotes around the output so that it 204*b4dd7d09SAndy Fiddaman can be reused as input. 205*b4dd7d09SAndy Fiddaman 5. The output for trap is in a format that can be reinput the 206*b4dd7d09SAndy Fiddaman the shell to restore the traps. 207*b4dd7d09SAndy Fiddaman 6. kill -l lists the signal names without numbers as 208*b4dd7d09SAndy Fiddaman required by the POSIX standard. 209*b4dd7d09SAndy Fiddaman 210*b4dd7d09SAndy Fiddaman b. The following changes have been made to shell functions: 211*b4dd7d09SAndy Fiddaman 1. The semantics of functions declared with name() has changed 212*b4dd7d09SAndy Fiddaman to conform with the IEEE-POSIX 1003.2 standard. In particular, 213*b4dd7d09SAndy Fiddaman these functions are executed in a dot script environment rather 214*b4dd7d09SAndy Fiddaman than a separated function environment so that there are no 215*b4dd7d09SAndy Fiddaman local variables and no scoping for traps. 216*b4dd7d09SAndy Fiddaman 2. Functions declared as function name, preserve the old ksh 217*b4dd7d09SAndy Fiddaman semantics can be also used as the first argument to the dot (.) 218*b4dd7d09SAndy Fiddaman command to have them executed in a dot script environment. 219*b4dd7d09SAndy Fiddaman 220*b4dd7d09SAndy Fiddaman c. The command search rules have changed as follows: 221*b4dd7d09SAndy Fiddaman 1. Special built-ins (those with a dagger in front of them) are 222*b4dd7d09SAndy Fiddaman executed first. 223*b4dd7d09SAndy Fiddaman 2. Functions are executed next. 224*b4dd7d09SAndy Fiddaman 3. Other built-ins that do not require an executable version 225*b4dd7d09SAndy Fiddaman (for example cd and read) come next. 226*b4dd7d09SAndy Fiddaman 4. If the command name contains a slash, the pathname corresponding 227*b4dd7d09SAndy Fiddaman to the command name is executed. 228*b4dd7d09SAndy Fiddaman 5. If name corresponds to a previously encountered pathname 229*b4dd7d09SAndy Fiddaman on the PATH variable, the corresponding command is executed. 230*b4dd7d09SAndy Fiddaman 6. If the command name does not contain a slash, then the PATH 231*b4dd7d09SAndy Fiddaman variable is used to find an executable by that name. If 232*b4dd7d09SAndy Fiddaman the directory that the command is found is also contained in 233*b4dd7d09SAndy Fiddaman the FPATH variable, then the command treated as a function. 234*b4dd7d09SAndy Fiddaman If the shell has a built-in version of the command corresponding 235*b4dd7d09SAndy Fiddaman to this command, then the built-in version of this command 236*b4dd7d09SAndy Fiddaman is executed. Otherwise, the shell remembers that pathname 237*b4dd7d09SAndy Fiddaman corresponding to this command name and executes this pathname. 238*b4dd7d09SAndy Fiddaman 7. If the name is not found on PATH, then the directories in 239*b4dd7d09SAndy Fiddaman FPATH are searched. If found, then the command is executed 240*b4dd7d09SAndy Fiddaman as a function. 241*b4dd7d09SAndy Fiddaman 242*b4dd7d09SAndy Fiddaman d. Built-in commands options now conform to the IEEE-POSIX 1003.2 243*b4dd7d09SAndy Fiddaman conventions with some additions. In particular, 244*b4dd7d09SAndy Fiddaman name -? 245*b4dd7d09SAndy Fiddaman will now print a Usage line for name, except for true, false, 246*b4dd7d09SAndy Fiddaman colon, login, newgrp, echo, [, and command. 247*b4dd7d09SAndy Fiddaman 248*b4dd7d09SAndy Fiddaman e. Tilde expansion is now performed as part of the word expansions. 249*b4dd7d09SAndy Fiddaman The effect of this is that if word begins with ~ in ${name op word}, 250*b4dd7d09SAndy Fiddaman it will be expanded unless escaped. 251*b4dd7d09SAndy Fiddaman 252*b4dd7d09SAndy Fiddaman f. Pathname expansion is no longer performed on redirection words 253*b4dd7d09SAndy Fiddaman unless the shell is interactive. 254*b4dd7d09SAndy Fiddaman 255*b4dd7d09SAndy Fiddaman g. Changes to shell and options: 256*b4dd7d09SAndy Fiddaman 1. The -n option has been enhanced to produce more warning and 257*b4dd7d09SAndy Fiddaman portability messages. 258*b4dd7d09SAndy Fiddaman 2. The -C option is equivalent to -o noclobber. Files are 259*b4dd7d09SAndy Fiddaman created with O_EXCL when -C is on. 260*b4dd7d09SAndy Fiddaman 261*b4dd7d09SAndy Fiddaman h. The following changes have been made to [[...]]: 262*b4dd7d09SAndy Fiddaman 1. A string by itself is equivalent to -n string. 263*b4dd7d09SAndy Fiddaman 2. -e has been added as equivalent to -a. 264*b4dd7d09SAndy Fiddaman 3. == has been added as equivalent =. 265*b4dd7d09SAndy Fiddaman 4. -a and = are now considered obsolete. 266*b4dd7d09SAndy Fiddaman 5. Arithmetic comparisons are now considered obsolete. 267*b4dd7d09SAndy Fiddaman 268*b4dd7d09SAndy Fiddaman i. kill has been changed as follows: 269*b4dd7d09SAndy Fiddaman 1. Signal names can be upper case or lower case. 270*b4dd7d09SAndy Fiddaman 2. Numerical arguments to kill -l cause the given signal names to 271*b4dd7d09SAndy Fiddaman be displayed. 272*b4dd7d09SAndy Fiddaman 3. String arguments to kill -l cause the given signal numbers to 273*b4dd7d09SAndy Fiddaman be displayed. 274*b4dd7d09SAndy Fiddaman 4. Synopsis changed for getopts conformance. 275*b4dd7d09SAndy Fiddaman 276*b4dd7d09SAndy Fiddaman j. print has a -f format option which is equivalent to 277*b4dd7d09SAndy Fiddaman the IEEE POSIX printf. Both print -f format, and 278*b4dd7d09SAndy Fiddaman printf have the following extensions from IEEE POSIX: 279*b4dd7d09SAndy Fiddaman 1. Floating point formats are supported. 280*b4dd7d09SAndy Fiddaman 2. Size and precision specifications can be *. 281*b4dd7d09SAndy Fiddaman 3. The %d option can take an argument after precision to 282*b4dd7d09SAndy Fiddaman specify the base that the number will be displayed. 283*b4dd7d09SAndy Fiddaman 4. A %q format can be used to output a string quoted so 284*b4dd7d09SAndy Fiddaman that it can be re-input to the shell. 285*b4dd7d09SAndy Fiddaman 5. A %P format can be used to output the shell pattern which 286*b4dd7d09SAndy Fiddaman corresponds to the give extended regular expression. 287*b4dd7d09SAndy Fiddaman 6. For numerical fields, the arguments can be arithmetic 288*b4dd7d09SAndy Fiddaman expressions which will be evaluated. 289*b4dd7d09SAndy Fiddaman 7. The %n format works as described in ANSI-C. 290*b4dd7d09SAndy Fiddaman 291*b4dd7d09SAndy Fiddaman k. The following changes have been made to fc: 292*b4dd7d09SAndy Fiddaman 1. It has been renamed hist. fc is now a predefined alias. 293*b4dd7d09SAndy Fiddaman 2. hist uses ${HISTEDIT:-$FCEDIT}. FCEDIT is obsolete. 294*b4dd7d09SAndy Fiddaman 3. A new -s option is equivalent to the obsolete -e -. 295*b4dd7d09SAndy Fiddaman 4. If the first argument refers to a command earlier than the 296*b4dd7d09SAndy Fiddaman first accessible command, it now implies the first accessible 297*b4dd7d09SAndy Fiddaman command, so that hist -l 1 lists all accessible history commands. 298*b4dd7d09SAndy Fiddaman 299*b4dd7d09SAndy Fiddaman l. The dot command (.) has changed as follows: 300*b4dd7d09SAndy Fiddaman 1. The argument can be the name of a function declared as 301*b4dd7d09SAndy Fiddaman function name. The function will execute without creating a 302*b4dd7d09SAndy Fiddaman new scope. 303*b4dd7d09SAndy Fiddaman 2. If there are arguments to the given script or function, 304*b4dd7d09SAndy Fiddaman the positional parameters are restored to their original 305*b4dd7d09SAndy Fiddaman value when . completes. 306*b4dd7d09SAndy Fiddaman 307*b4dd7d09SAndy Fiddaman m. The read built-in has been changed as follows: 308*b4dd7d09SAndy Fiddaman 1. A -A option to read has been added to allow the fields to be 309*b4dd7d09SAndy Fiddaman read into an indexed array. 310*b4dd7d09SAndy Fiddaman 2. A -t n option has been added which causes read to 311*b4dd7d09SAndy Fiddaman timeout after n seconds when reading from a slow device. 312*b4dd7d09SAndy Fiddaman 3. A -d char option has been added which causes the read 313*b4dd7d09SAndy Fiddaman to terminate at char rather than at new-line. 314*b4dd7d09SAndy Fiddaman 315*b4dd7d09SAndy Fiddaman n. The trap command has been changed as follows: 316*b4dd7d09SAndy Fiddaman 1. Trap names can be either upper case or lower case. 317*b4dd7d09SAndy Fiddaman 2. Trap -p cause only the specified trap values to be displayed. 318*b4dd7d09SAndy Fiddaman 3. The value of trap in a subshell will be the value in the parent 319*b4dd7d09SAndy Fiddaman shell until a call to trap which changes the trap settings has 320*b4dd7d09SAndy Fiddaman been made. Thus, savetraps=$(trap) works as required by the 321*b4dd7d09SAndy Fiddaman POSIX standard. 322*b4dd7d09SAndy Fiddaman 323*b4dd7d09SAndy Fiddaman o. The exec command has been extended as follows: 324*b4dd7d09SAndy Fiddaman 1. The -c option clears the environment first. 325*b4dd7d09SAndy Fiddaman 2. The -a name option sets argv[0] to name for the program. 326*b4dd7d09SAndy Fiddaman 327*b4dd7d09SAndy Fiddaman p. true and false are built-ins, not aliases to built-ins. 328*b4dd7d09SAndy Fiddaman 329*b4dd7d09SAndy Fiddaman q. test has been modified to conform to the IEEE-POSIX 1003.2 330*b4dd7d09SAndy Fiddaman standard when there are three or less arguments. 331*b4dd7d09SAndy Fiddaman 332*b4dd7d09SAndy Fiddaman r. umask -S option displays the mask in a symbolic format. 333*b4dd7d09SAndy Fiddaman 334*b4dd7d09SAndy Fiddaman s. wait now returns the correct exit status of any previous 335*b4dd7d09SAndy Fiddaman background job that has not been waited for, not just 336*b4dd7d09SAndy Fiddaman the most recent one. 337*b4dd7d09SAndy Fiddaman 338*b4dd7d09SAndy Fiddaman t. The whence built-in has an option -a which causes all 339*b4dd7d09SAndy Fiddaman uses for the given command name to be reported. 340*b4dd7d09SAndy Fiddaman 341*b4dd7d09SAndy Fiddaman u. unalias has -a option to clear all the aliases. 342*b4dd7d09SAndy Fiddaman 343*b4dd7d09SAndy Fiddaman v. The times built-in command has been removed. The time 344*b4dd7d09SAndy Fiddaman reserved word, without a command, gives time cumulative 345*b4dd7d09SAndy Fiddaman time for the shell and its children. A built-in alias 346*b4dd7d09SAndy Fiddaman for times should enable scripts using times to continue 347*b4dd7d09SAndy Fiddaman to run. 348*b4dd7d09SAndy Fiddaman 349*b4dd7d09SAndy Fiddaman w. Command substitution and arithmetic substitution will now be 350*b4dd7d09SAndy Fiddaman performed for PS1, ENV, and PS4 evaluation in addition to 351*b4dd7d09SAndy Fiddaman parameter expansion. 352*b4dd7d09SAndy Fiddaman 353*b4dd7d09SAndy Fiddaman x. The SECONDS variable now displays elapsed time in floating 354*b4dd7d09SAndy Fiddaman point seconds with 3 places after the decimal point by 355*b4dd7d09SAndy Fiddaman default. 356*b4dd7d09SAndy Fiddaman 357*b4dd7d09SAndy Fiddaman y. The getopts built-in now handles the complete libast optget 358*b4dd7d09SAndy Fiddaman functionality. If any errors have occurred with getopts 359*b4dd7d09SAndy Fiddaman when it has reached the end of arguments, then the Usage 360*b4dd7d09SAndy Fiddaman message will be generated from the option string and the 361*b4dd7d09SAndy Fiddaman exit status from getopts will be 2 rather than 1. The 362*b4dd7d09SAndy Fiddaman usage message will be stored in the OPTARG variable if 363*b4dd7d09SAndy Fiddaman the option string contains a leading colon; otherwise 364*b4dd7d09SAndy Fiddaman it will be printed on standard error automatically. 365*b4dd7d09SAndy Fiddaman 366*b4dd7d09SAndy Fiddaman z. THE ENV file is only processed for interactive shell 367*b4dd7d09SAndy Fiddaman invocations. In addition, the -x attributes for 368*b4dd7d09SAndy Fiddaman aliases and functions is ignored. 369*b4dd7d09SAndy Fiddaman 370*b4dd7d09SAndy Fiddaman aa. The built-in edit modes have been changed as follows: 371*b4dd7d09SAndy Fiddaman 1. The pathname completion and pathname listing options 372*b4dd7d09SAndy Fiddaman now perform command completion and command listing 373*b4dd7d09SAndy Fiddaman when applied to a word in the command position. 374*b4dd7d09SAndy Fiddaman 2. In emacs mode ^N as the first related command after 375*b4dd7d09SAndy Fiddaman the prompt will move to the next command relative to the 376*b4dd7d09SAndy Fiddaman last known history position. 377*b4dd7d09SAndy Fiddaman 3. In emacs mode, successive kill and delete commands will 378*b4dd7d09SAndy Fiddaman accumulate their data in the kill buffer, by appending or 379*b4dd7d09SAndy Fiddaman prepending as appropriate. This mode will be reset by any 380*b4dd7d09SAndy Fiddaman command not adding something to the kill buffer. 381*b4dd7d09SAndy Fiddaman 4. The control-T of emacs mode has been changed to behave like 382*b4dd7d09SAndy Fiddaman control-T in gnu-emacs. 383*b4dd7d09SAndy Fiddaman bb. The TMOUT variable also sets a limit for select timeouts 384*b4dd7d09SAndy Fiddaman and default timeouts for read. 385*b4dd7d09SAndy Fiddaman 386*b4dd7d09SAndy Fiddaman 387*b4dd7d09SAndy Fiddaman4. The source code has undergone significant modification. 388*b4dd7d09SAndy Fiddaman a. Much of the code has been rewritten, In many cases this has 389*b4dd7d09SAndy Fiddaman resulted in significant performance improvement. 390*b4dd7d09SAndy Fiddaman 391*b4dd7d09SAndy Fiddaman b. The code is organized differently. See the README files 392*b4dd7d09SAndy Fiddaman for more details. 393*b4dd7d09SAndy Fiddaman 394*b4dd7d09SAndy Fiddaman c. Most configuration parameters now get generated using 395*b4dd7d09SAndy Fiddaman the FEATURE mechanism of nmake. Other options are set 396*b4dd7d09SAndy Fiddaman in the OPTIONS file. 397*b4dd7d09SAndy Fiddaman 398*b4dd7d09SAndy Fiddaman c. The are several new compile time options. See the README 399*b4dd7d09SAndy Fiddaman file for details. Some of the old ones have been removed. 400*b4dd7d09SAndy Fiddaman 401*b4dd7d09SAndy Fiddaman d. The install script is a Mamfile that is generated by 402*b4dd7d09SAndy Fiddaman nmake and processed by a script that comes with the 403*b4dd7d09SAndy Fiddaman distribution. 404*b4dd7d09SAndy Fiddaman 405*b4dd7d09SAndy Fiddaman e. There are far fewer global names. This should make it 406*b4dd7d09SAndy Fiddaman must easier to add built-in commands without worrying 407*b4dd7d09SAndy Fiddaman about conflicts. 408*b4dd7d09SAndy Fiddaman 409*b4dd7d09SAndy Fiddaman f. The code uses the sfio library which makes it possible 410*b4dd7d09SAndy Fiddaman to mix with stdio. 411*b4dd7d09SAndy Fiddaman 412*b4dd7d09SAndy Fiddaman g. The code is written in ANSI C with full prototypes. 413*b4dd7d09SAndy Fiddaman The code is based on the IEEE POSIX 1003.1 standard. 414*b4dd7d09SAndy Fiddaman The code can be compiled with K&R C and with C++ by 415*b4dd7d09SAndy Fiddaman using the ANSI cpp that comes with nmake or running 416*b4dd7d09SAndy Fiddaman the code through the proto filter before pre-processing. 417*b4dd7d09SAndy Fiddaman This happens automatically with our shipping system. 418*b4dd7d09SAndy Fiddaman 419*b4dd7d09SAndy Fiddaman h. There is a programming interface for capturing references 420*b4dd7d09SAndy Fiddaman and assignment to shell variables. It is also possible 421*b4dd7d09SAndy Fiddaman to intercept variable creation and supply the array processing 422*b4dd7d09SAndy Fiddaman function for that variable. See nval.3 for a description. 423