xref: /titanic_52/usr/src/contrib/ast/src/cmd/ksh93/COMPATIBILITY (revision 906afcb89d0412cc073b95c2d701a804a8cdb62c)
1*906afcb8SAndy Fiddaman
2*906afcb8SAndy Fiddaman		KSH-93 VS. KSH-88
3*906afcb8SAndy Fiddaman
4*906afcb8SAndy Fiddaman
5*906afcb8SAndy FiddamanThe following is a list of known incompatibilities between ksh-93 and ksh-88.
6*906afcb8SAndy FiddamanI have not include cases that are clearly bugs in ksh-88.  I also have
7*906afcb8SAndy Fiddamanomitted features that are completely upward compatible.
8*906afcb8SAndy Fiddaman
9*906afcb8SAndy Fiddaman1.	Functions, defined with name() with ksh-93 are compatible with
10*906afcb8SAndy Fiddaman	the POSIX standard, not with ksh-88.  No local variables are
11*906afcb8SAndy Fiddaman	permitted, and there is no separate scope.  Functions defined
12*906afcb8SAndy Fiddaman	with the function name syntax, maintain compatibility.
13*906afcb8SAndy Fiddaman	This also affects function traces.
14*906afcb8SAndy Fiddaman
15*906afcb8SAndy Fiddaman2.	! is now a reserved word.  As a result, any command by that
16*906afcb8SAndy Fiddaman	name will no longer work with ksh-93.
17*906afcb8SAndy Fiddaman
18*906afcb8SAndy Fiddaman3.	The -x attribute of alias and typeset -f is no longer
19*906afcb8SAndy Fiddaman	effective and the ENV file is only read for interactive
20*906afcb8SAndy Fiddaman	shells.  You need to use FPATH to make function definitions
21*906afcb8SAndy Fiddaman	visible to scripts.
22*906afcb8SAndy Fiddaman
23*906afcb8SAndy Fiddaman4.	A built-in command named command has been added which is
24*906afcb8SAndy Fiddaman	always found before the PATH search.  Any script which uses
25*906afcb8SAndy Fiddaman	this name as the name of a command (or function) will not
26*906afcb8SAndy Fiddaman	be compatible.
27*906afcb8SAndy Fiddaman
28*906afcb8SAndy Fiddaman5.	The output format for some built-ins has changed.  In particular
29*906afcb8SAndy Fiddaman	the output format for set, typeset and alias now have single
30*906afcb8SAndy Fiddaman	quotes around values that have special characters.  The output
31*906afcb8SAndy Fiddaman	for trap without arguments has a format that can be used as input.
32*906afcb8SAndy Fiddaman
33*906afcb8SAndy Fiddaman6.	With ksh-88, a dollar sign ($') followed by a single quote was
34*906afcb8SAndy Fiddaman	interpreted literally.  Now it is an ANSI-C string.  You
35*906afcb8SAndy Fiddaman	must quote the dollar sign to get the previous behavior.
36*906afcb8SAndy Fiddaman	Also, a $ in front of a " indicates that the string needs
37*906afcb8SAndy Fiddaman	to be translated for locales other than C or POSIX.  The $
38*906afcb8SAndy Fiddaman	is ignored in the C and POSIX locale.
39*906afcb8SAndy Fiddaman
40*906afcb8SAndy Fiddaman7.	With ksh-88, tilde expansion did not take place inside ${...}.
41*906afcb8SAndy Fiddaman	with ksh-93, ${foo-~} will cause tilde expansion if foo is
42*906afcb8SAndy Fiddaman	not set.  You need to escape the ~ for the previous behavior.
43*906afcb8SAndy Fiddaman
44*906afcb8SAndy Fiddaman8.      Some changes in the tokenizing rules where made that might
45*906afcb8SAndy Fiddaman	cause some scripts with previously ambiguous use of quoting
46*906afcb8SAndy Fiddaman	to produce syntax errors.
47*906afcb8SAndy Fiddaman
48*906afcb8SAndy Fiddaman9.	Programs that rely on specific exit values for the shell,
49*906afcb8SAndy Fiddaman	(rather than 0 or non-zero) may not be compatible.  The
50*906afcb8SAndy Fiddaman	exit status for many shell failures has been changed.
51*906afcb8SAndy Fiddaman
52*906afcb8SAndy Fiddaman10.	Built-ins in ksh-88 were always executed before looking for
53*906afcb8SAndy Fiddaman	the command in the PATH variable.  This is no longer true.
54*906afcb8SAndy Fiddaman	Thus, with ksh-93, if you have the current directory first
55*906afcb8SAndy Fiddaman	in your PATH, and you have a program named test in your
56*906afcb8SAndy Fiddaman	directory, it will be executed when you type test; the
57*906afcb8SAndy Fiddaman	built-in version will be run at the point /bin is found
58*906afcb8SAndy Fiddaman	in your PATH.
59*906afcb8SAndy Fiddaman
60*906afcb8SAndy Fiddaman11.	Some undocumented combinations of argument passing to ksh
61*906afcb8SAndy Fiddaman	builtins no longer works since ksh-93 is getopts conforming
62*906afcb8SAndy Fiddaman	with respect to its built-ins.  For example, typeset -8i
63*906afcb8SAndy Fiddaman	previously would work as a synonym for typeset -i8.
64*906afcb8SAndy Fiddaman
65*906afcb8SAndy Fiddaman12.	Command substitution and arithmetic expansion are now performed
66*906afcb8SAndy Fiddaman	on PS1, PS3, and ENV when they are expanded.  Thus,  ` and $(
67*906afcb8SAndy Fiddaman	as part of the value of these variables must be preceded by a \
68*906afcb8SAndy Fiddaman	to preserve their previous behavior.
69*906afcb8SAndy Fiddaman
70*906afcb8SAndy Fiddaman13.	The ERRNO variable has been dropped.
71*906afcb8SAndy Fiddaman
72*906afcb8SAndy Fiddaman14.	If the file name following a redirection symbol contain pattern
73*906afcb8SAndy Fiddaman	characters they will only be expanded for interactive shells.
74*906afcb8SAndy Fiddaman
75*906afcb8SAndy Fiddaman15.	The arguments to a dot script will be restored when it completes.
76*906afcb8SAndy Fiddaman
77*906afcb8SAndy Fiddaman16.	The list of tracked aliases is not displayed with alias unless
78*906afcb8SAndy Fiddaman	the -t option is specified.
79*906afcb8SAndy Fiddaman
80*906afcb8SAndy Fiddaman17.	The POSIX standard requires that test "$arg" have exit status
81*906afcb8SAndy Fiddaman	of 0, if and only if $arg is null.  However, since this breaks
82*906afcb8SAndy Fiddaman	programs that use test -t, ksh-93 treats an explicit test -t
83*906afcb8SAndy Fiddaman	as if the user had entered test -t 1.
84*906afcb8SAndy Fiddaman
85*906afcb8SAndy Fiddaman18.	The ^T directive of emacs mode has been changed to work the
86*906afcb8SAndy Fiddaman	way it does in gnu-emacs.
87*906afcb8SAndy Fiddaman
88*906afcb8SAndy Fiddaman19.	ksh-88 allowed unbalanced parenthes within ${name op val} whereas
89*906afcb8SAndy Fiddaman	ksh-93 does not.  Thus, ${foo-(} needs to be written as ${foo-\(}
90*906afcb8SAndy Fiddaman	which works with both versions.
91*906afcb8SAndy Fiddaman
92*906afcb8SAndy Fiddaman20.     kill -l in ksh-93 lists only the signal names, not their numerical
93*906afcb8SAndy Fiddaman	values.
94*906afcb8SAndy Fiddaman
95*906afcb8SAndy Fiddaman21.	Local variables defined by typeset are statically scoped in
96*906afcb8SAndy Fiddaman	ksh-93.  In ksh-88 they were dynamically scoped although this
97*906afcb8SAndy Fiddaman	behavior was never documented.
98*906afcb8SAndy Fiddaman
99*906afcb8SAndy Fiddaman22.	The value of the variable given to getopts is set to ? when
100*906afcb8SAndy Fiddaman	the end-of-options is reached to conform to the POSIX standard.
101*906afcb8SAndy Fiddaman
102*906afcb8SAndy Fiddaman23.	Since the POSIX standard requires that octal constants be
103*906afcb8SAndy Fiddaman	recongnized, doing arithmetic on typeset -Z variables can
104*906afcb8SAndy Fiddaman	yield different results that with ksh-88.  Most of these
105*906afcb8SAndy Fiddaman	differences were eliminated in ksh-93o.  Starting in ksh-93u+, the
106*906afcb8SAndy Fiddaman	let command no longer recognizes octal constants starting with 0
107*906afcb8SAndy Fiddaman	for compatibility with ksh-88 unless the option letoctal is on.
108*906afcb8SAndy Fiddaman
109*906afcb8SAndy Fiddaman24.	Starting after ksh-93l, If you run ksh name, where name does
110*906afcb8SAndy Fiddaman	not contain a /, the current directory will be searched
111*906afcb8SAndy Fiddaman	before doing a path search on name as required by the POSIX
112*906afcb8SAndy Fiddaman	shell standard.
113*906afcb8SAndy Fiddaman
114*906afcb8SAndy Fiddaman25.	In ksh-93, cd - will output the directory that it changes
115*906afcb8SAndy Fiddaman	to on standard output as required by X/Open.  With ksh-88,
116*906afcb8SAndy Fiddaman	this only happened for interactive shells.
117*906afcb8SAndy Fiddaman
118*906afcb8SAndy Fiddaman26.	As an undocumented feature of ksh-88, a leading 0 to an
119*906afcb8SAndy Fiddaman	assignment of an integer variable caused that variable
120*906afcb8SAndy Fiddaman	to be treated as unsigned.  This behavior was removed
121*906afcb8SAndy Fiddaman	starting in ksh-93p.
122*906afcb8SAndy Fiddaman
123*906afcb8SAndy Fiddaman27.	The getopts builtin in ksh-93 requires that optstring contain
124*906afcb8SAndy Fiddaman	a leading + to allow options to begin with a +.
125*906afcb8SAndy Fiddaman
126*906afcb8SAndy Fiddaman28.	In emacs/gmacs mode, control-v will not display the version when
127*906afcb8SAndy Fiddaman	the stty lnext character is set to control-v or is unset.
128*906afcb8SAndy Fiddaman	The sequence escape control-v will display the shell version.
129*906afcb8SAndy Fiddaman
130*906afcb8SAndy Fiddaman29.	In ksh-88, DEBUG traps were executed. after each command.  In ksh-93
131*906afcb8SAndy Fiddaman	DEBUG traps are exeucted before each command.
132*906afcb8SAndy Fiddaman
133*906afcb8SAndy Fiddaman30.	In ksh-88, a redirection to a file name given by an empty string was
134*906afcb8SAndy Fiddaman	ignored.  In ksh-93, this is an error.
135*906afcb8SAndy FiddamanI am interested in expanding this list so please let me know if you
136*906afcb8SAndy Fiddamanuncover any others.
137