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