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