COMPATIBILITY revision 7c2fbfb345896881c631598ee3852ce9ce33fb07
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin KSH-93 VS. KSH-88
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinThe following is a list of known incompatibilities between ksh-93 and ksh-88.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinI have not include cases that are clearly bugs in ksh-88. I also have
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinomitted features that are completely upward compatible.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin1. Functions, defined with name() with ksh-93 are compatible with
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin the POSIX standard, not with ksh-88. No local variables are
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin permitted, and there is no separate scope. Functions defined
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin with the function name syntax, maintain compatibility.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin This also affects function traces.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin2. ! is now a reserved word. As a result, any command by that
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin name will no longer work with ksh-93.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin3. The -x attribute of alias and typeset -f is no longer
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin effective and the ENV file is only read for interactive
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin shells. You need to use FPATH to make function definitions
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin visible to scripts.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin4. A built-in command named command has been added which is
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin always found before the PATH search. Any script which uses
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin this name as the name of a command (or function) will not
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin be compatible.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin5. The output format for some built-ins has changed. In particular
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin the output format for set, typeset and alias now have single
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin quotes around values that have special characters. The output
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin for trap without arguments has a format that can be used as input.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin6. With ksh-88, a dollar sign ($') followed by a single quote was
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin interpreted literally. Now it is an ANSI-C string. You
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin must quote the dollar sign to get the previous behavior.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Also, a $ in front of a " indicates that the string needs
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin to be translated for locales other than C or POSIX. The $
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin is ignored in the C and POSIX locale.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin7. With ksh-88, tilde expansion did not take place inside ${...}.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin with ksh-93, ${foo-~} will cause tilde expansion if foo is
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin not set. You need to escape the ~ for the previous behavior.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin8. Some changes in the tokenizing rules where made that might
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin cause some scripts with previously ambiguous use of quoting
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin to produce syntax errors.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin9. Programs that rely on specific exit values for the shell,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin (rather than 0 or non-zero) may not be compatible. The
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin exit status for many shell failures has been changed.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin10. Built-ins in ksh-88 were always executed before looking for
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin the command in the PATH variable. This is no longer true.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin Thus, with ksh-93, if you have the current directory first
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin in your PATH, and you have a program named test in your
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin directory, it will be executed when you type test; the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin built-in version will be run at the point /bin is found
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin in your PATH.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin11. Some undocumented combinations of argument passing to ksh
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin builtins no longer works since ksh-93 is getopts conforming
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin with respect to its built-ins. For example, typeset -8i
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin previously would work as a synonym for typeset -i8.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin12. Command substitution and arithmetic expansion are now performed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin on PS1, PS3, and ENV when they are expanded. Thus, ` and $(
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin as part of the value of these variables must be preceded by a \
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin to preserve their previous behavior.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin13. The ERRNO variable has been dropped.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin14. If the file name following a redirection symbol contain pattern
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin characters they will only be expanded for interactive shells.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin15. The arguments to a dot script will be restored when it completes.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin16. The list of tracked aliases is not displayed with alias unless
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin the -t option is specified.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin17. The POSIX standard requires that test "$arg" have exit status
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin of 0, if and only if $arg is null. However, since this breaks
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin programs that use test -t, ksh93 treats an explicit test -t
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin as if the user had entered test -t 1.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin18. The ^T directive of emacs mode has been changed to work the
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin way it does in gnu-emacs.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin19. ksh-88 allowed unbalanced parenthes within ${name op val} whereas
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin ksh-93 does not. Thus, ${foo-(} needs to be written as ${foo-\(}
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin which works with both versions.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin20. kill -l in ksh-93 lists only the signal names, not their numerical
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin21. Local variables defined by typeset are statically scoped in
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin ksh93. In ksh88 they were dynamically scoped although this
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin behavior was never documented.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin22. The value of the variable given to getopts is set to ? when
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin the end-of-options is reached to conform to the POSIX standard.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin23. Since the POSIX standard requires that octal constants be
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin recongnized, doing arithmetic on typeset -Z variables can
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin yield different results that with ksh88. Most of these
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin differences were eliminated in ksh93o.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin24. Starting after ksh93l, If you run ksh name, where name does
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin not contain a /, the current directory will be searched
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin before doing a path search on name as required by the POSIX
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin shell standard.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin25. In ksh93, cd - will output the directory that it changes
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin to on standard output as required by X/Open. With ksh88,
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin this only happened for interactive shells.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin26. As an undocumented feature of ksh-88, a leading 0 to an
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin assignment of an integer variable caused that variable
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin to be treated as unsigned. This behavior was removed
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin starting in ksh93p.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin27. The getopts builtin in ksh93 requires that optstring contain
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin a leading + to allow options to begin with a +.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin28. In emacs/gmacs mode, control-v will not display the version when
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin the stty lnext character is set to control-v or is unset.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chin The sequence escape control-v will display the shell version.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin29. In ksh88, DEBUG traps were executed. after each command. In ksh93
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin DEBUG traps are exeucted before each command.
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin30. In ksh88, a redirection to a file name given by an empty string was
7c2fbfb345896881c631598ee3852ce9ce33fb07April Chin ignored. In ksh93, this is an error.
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinI am interested in expanding this list so please let me know if you
da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968chinuncover any others.