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