xref: /onnv-gate/usr/src/lib/libshell/common/COMPATIBILITY (revision 8462:6e341f5569ba)
14887Schin
24887Schin			KSH-93 VS. KSH-88
34887Schin
44887Schin
54887SchinThe following is a list of known incompatibilities between ksh-93 and ksh-88.
64887SchinI have not include cases that are clearly bugs in ksh-88.  I also have
74887Schinomitted features that are completely upward compatible.
84887Schin
94887Schin1.	Functions, defined with name() with ksh-93 are compatible with
104887Schin	the POSIX standard, not with ksh-88.  No local variables are
114887Schin	permitted, and there is no separate scope.  Functions defined
124887Schin	with the function name syntax, maintain compatibility.
134887Schin	This also affects function traces.
144887Schin
154887Schin2.	! is now a reserved word.  As a result, any command by that
164887Schin	name will no longer work with ksh-93.
174887Schin
184887Schin3.	The -x attribute of alias and typeset -f is no longer
194887Schin	effective and the ENV file is only read for interactive
204887Schin	shells.  You need to use FPATH to make function definitions
214887Schin	visible to scripts.
224887Schin
234887Schin4.	A built-in command named command has been added which is
244887Schin	always found before the PATH search.  Any script which uses
254887Schin	this name as the name of a command (or function) will not
264887Schin	be compatible.
274887Schin
284887Schin5.	The output format for some built-ins has changed.  In particular
294887Schin	the output format for set, typeset and alias now have single
304887Schin	quotes around values that have special characters.  The output
314887Schin	for trap without arguments has a format that can be used as input.
324887Schin
334887Schin6.	With ksh-88, a dollar sign ($') followed by a single quote was
344887Schin	interpreted literally.  Now it is an ANSI-C string.  You
354887Schin	must quote the dollar sign to get the previous behavior.
364887Schin	Also, a $ in front of a " indicates that the string needs
374887Schin	to be translated for locales other than C or POSIX.  The $
384887Schin	is ignored in the C and POSIX locale.
394887Schin
404887Schin7.	With ksh-88, tilde expansion did not take place inside ${...}.
414887Schin	with ksh-93, ${foo-~} will cause tilde expansion if foo is
424887Schin	not set.  You need to escape the ~ for the previous behavior.
434887Schin
444887Schin8.      Some changes in the tokenizing rules where made that might
454887Schin	cause some scripts with previously ambiguous use of quoting
464887Schin	to produce syntax errors.
474887Schin
484887Schin9.	Programs that rely on specific exit values for the shell,
494887Schin	(rather than 0 or non-zero) may not be compatible.  The
504887Schin	exit status for many shell failures has been changed.
514887Schin
524887Schin10.	Built-ins in ksh-88 were always executed before looking for
534887Schin	the command in the PATH variable.  This is no longer true.
544887Schin	Thus, with ksh-93, if you have the current directory first
554887Schin	in your PATH, and you have a program named test in your
564887Schin	directory, it will be executed when you type test; the
574887Schin	built-in version will be run at the point /bin is found
584887Schin	in your PATH.
594887Schin
604887Schin11.	Some undocumented combinations of argument passing to ksh
614887Schin	builtins no longer works since ksh-93 is getopts conforming
624887Schin	with respect to its built-ins.  For example, typeset -8i
634887Schin	previously would work as a synonym for typeset -i8.
644887Schin
654887Schin12.	Command substitution and arithmetic expansion are now performed
664887Schin	on PS1, PS3, and ENV when they are expanded.  Thus,  ` and $(
674887Schin	as part of the value of these variables must be preceded by a \
684887Schin	to preserve their previous behavior.
694887Schin
704887Schin13.	The ERRNO variable has been dropped.
714887Schin
724887Schin14.	If the file name following a redirection symbol contain pattern
734887Schin	characters they will only be expanded for interactive shells.
744887Schin
754887Schin15.	The arguments to a dot script will be restored when it completes.
764887Schin
774887Schin16.	The list of tracked aliases is not displayed with alias unless
784887Schin	the -t option is specified.
794887Schin
804887Schin17.	The POSIX standard requires that test "$arg" have exit status
814887Schin	of 0, if and only if $arg is null.  However, since this breaks
824887Schin	programs that use test -t, ksh93 treats an explicit test -t
834887Schin	as if the user had entered test -t 1.
844887Schin
854887Schin18.	The ^T directive of emacs mode has been changed to work the
864887Schin	way it does in gnu-emacs.
874887Schin
884887Schin19.	ksh-88 allowed unbalanced parenthes within ${name op val} whereas
894887Schin	ksh-93 does not.  Thus, ${foo-(} needs to be written as ${foo-\(}
904887Schin	which works with both versions.
914887Schin
924887Schin20.     kill -l in ksh-93 lists only the signal names, not their numerical
934887Schin	values.
944887Schin
954887Schin21.	Local variables defined by typeset are statically scoped in
964887Schin	ksh93.  In ksh88 they were dynamically scoped although this
974887Schin	behavior was never documented.
984887Schin
994887Schin22.	The value of the variable given to getopts is set to ? when
1004887Schin	the end-of-options is reached to conform to the POSIX standard.
1014887Schin
1024887Schin23.	Since the POSIX standard requires that octal constants be
1034887Schin	recongnized, doing arithmetic on typeset -Z variables can
1044887Schin	yield different results that with ksh88.  Most of these
1054887Schin	differences were eliminated in ksh93o.
1064887Schin
1074887Schin24.	Starting after ksh93l, If you run ksh name, where name does
1084887Schin	not contain a /, the current directory will be searched
1094887Schin	before doing a path search on name as required by the POSIX
1104887Schin	shell standard.
1114887Schin
1124887Schin25.	In ksh93, cd - will output the directory that it changes
1134887Schin	to on standard output as required by X/Open.  With ksh88,
1144887Schin	this only happened for interactive shells.
1154887Schin
1164887Schin26.	As an undocumented feature of ksh-88, a leading 0 to an
1174887Schin	assignment of an integer variable caused that variable
1184887Schin	to be treated as unsigned.  This behavior was removed
1194887Schin	starting in ksh93p.
1204887Schin
1214887Schin27.	The getopts builtin in ksh93 requires that optstring contain
1224887Schin	a leading + to allow options to begin with a +.
1234887Schin
1244887Schin28.	In emacs/gmacs mode, control-v will not display the version when
1254887Schin	the stty lnext character is set to control-v or is unset.
1264887Schin	The sequence escape control-v will display the shell version.
1274887Schin
128*8462SApril.Chin@Sun.COM29.	In ksh88, DEBUG traps were executed. after each command.  In ksh93
129*8462SApril.Chin@Sun.COM	DEBUG traps are exeucted before each command.
130*8462SApril.Chin@Sun.COM
131*8462SApril.Chin@Sun.COM30.	In ksh88, a redirection to a file name given by an empty string was
132*8462SApril.Chin@Sun.COM	ignored.  In ksh93, this is an error.
1334887SchinI am interested in expanding this list so please let me know if you
1344887Schinuncover any others.
135