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