Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

4.81. ksh

An updated ksh package that fixes multiple bugs and adds one enhancement is now available for Red Hat Enterprise Linux 5.
KSH-93 is the most recent version of the KornShell by David Korn of AT&T Bell Laboratories. KornShell is a shell programming language which is also compatible with sh, the original Bourne Shell.

Bug Fixes

BZ#759498
When exiting a subshell after a command substitution, ksh could prematurely exit without any error. With this update, ksh no longer terminates under these circumstances and all subsequent commands are processed correctly.
BZ#743357
KornShell keeps a list of all non-zero return codes of old child processes with the list size limited by the maximum number of child processes. Previously, this list was not updated properly. Therefore, when PID numbers were reused on long running shells, ksh could erroneously return the exit code of the old process that had used the same PID number like the process that just exited. With this update ksh has been modified to ensure that the list of child processes return codes is updated properly, and the error no longer occurs in the scenario described.
BZ#739664
In KSH-93, when calling a function that was defined by using the function keyword, an additional subprocess was created, unlike for functions defined without this keyword. This update applies an upstream patch, which modifies behavior of KSH-93 so that no additional subprocesses are created under these conditions.
BZ#736462
On Red Hat Enterprise Linux 5, not all kernel methods and user space utilities for file time stamps manipulation support nanosecond resolution. Previous ksh versions always used nanosecond resolution when comparing modification date of files. Therefore, when comparing files on ext4 file systems, ksh returned unexpected results even though ext4 file systems support nanosecond resolution. With this update, ksh has been modified to use only second resolution and file time stamps comparison now produces correct results in the scenario described.
BZ#736195, BZ#709774
Previously, when executing multiple piped commands within a script, there was a large time window between creating the child process and executing a command in the child process. This caused various problems with scripts relying on output of the ps command because the ps command detected more instances of the same script. With this update, this time window has been significantly reduced so the ps command now detects only one script instance.
BZ#698874
When running a script, the previous version of ksh could incorrectly consider the eval command to be the last in the script, and did not run it in a separate process. Consequently, using eval or executing commands from another file (that is, by using the . built-in command) may have prevented ksh from executing any subsequent commands. With this update, the underlying source code has been adapted to determine whether a script contains other commands and to perform the selected action in a separate process if it does. As a result, ksh now executes all commands in a script as expected.
BZ#690816
Previously, ksh treated an array declaration as a definition. Consequently, the array contained one element after the declaration. This bug has been fixed, and now an array is correctly reported as empty after a declaration.
BZ#683722, BZ#727891
If the IFS variable was unset inside a function used in a script, the memory being used was erroneously freed. Consequently, ksh terminated unexpectedly with a segmentation fault. With this update, ksh allows the IFS variable to be unset, but without freeing the memory so that ksh no longer crashes under these circumstances.
BZ#616853
Assigning a value to an array variable during the execution of the typeset command could cause ksh to terminate unexpectedly with a segmentation fault. This update corrects the array handling in this command and ksh no longer crashes.
BZ#586923
Due to a memory leak in the ksh executable, the performance of long running scripts could decrease significantly over time. With this update, the underlying source code has been modified to prevent this memory leak, and the execution of long running scripts is no longer slowed down.
BZ#691933
In POSIX functions, a function defined without using the function keyword, the value of the variable $0 was changed to the name of the function instead of keeping the original value, the name of the caller function. With this update, an upstream patch has been applied to correct the code and ksh keeps the name of the caller function in $0 as expected.
BZ#642508
Prior to this update, ksh did not close a file containing an auto-loaded function definition. After loading several functions, ksh could have easily exceeded the system's limit on the number of open files. With this update, files containing auto-loaded functions are properly closed, thus, the number of opened files no longer increases with usage.
BZ#615284
When a ksh script contained the trap command to capture a SIGPIPE signal, sending this signal via the built-in echo command could cause its output to be incorrectly added to the redirected output of an external command. With this update, ksh now flushes the output buffer before redirecting any output streams.
BZ#601555
Due to incorrect signal handling, receiving a signal while still processing the previously sent signal caused ksh to terminate unexpectedly with a segmentation fault. With this update, the subsequent signals are deferred until the current signal is processed; thus, ksh no longer crashes.
BZ#743302
Previously, ksh became unresponsive when pipes were used in an eval argument. With this update, an upstream patch has been applied and the ksh no longer hangs in the scenario described.
BZ#712349
Previously, the ulimit built-in function did not properly handle setting of the limit for virtual memory usage, which was set by the -v parameter. Consequently, every time this limit was modified, also the CPU time limit was changed, which was undesirable. This update modifies handling of the virtual memory limit so that it does not influence the CPU time limit anymore.
BZ#699823, BZ#726199
When running a ksh script, the exit code of a child process was not preserved. Consequently, when a script asked for such an exit code, the wrong value was reported. With this update, ksh now stores exit codes of child processes so that the exit codes are available for the future use.
BZ#659459
When a ksh script created a file and immediately opened it after the creation, the operation failed. This happened because, in some cases, the file being created did not exist yet. With this update, this race condition has been fixed and once a file is created, it is immediately available for any following commands.
BZ#647524
File name completion used after an environment variable failed and ksh reported a bad substitution error. With this update, an upstream patch has been applied which fixes the problem.
BZ#640379
Previously, ksh did not always wait for a pipeline to complete when the pipefail option was used. Consequently, a failed exit status was erroneously reported even when the pipeline had not failed. With this update, the code has been improved and the pipefail option now functions as expected.
BZ#584704
In ksh, when performing nested command substitution, each command is performed in a separate coprocess. The previous version of ksh did not handle the nested command substitutions correctly, which could result in a race condition between job routines in the signal handler and the parent process. Subsequently, ksh could erroneously close stdout of the running coprocess. With this update, ksh now checks whether the coprocess is running before it attempts to close its file descriptor. KornShell now handles the nested command substitutions properly.
BZ#650998
Previously, ksh did not restore file handles after executing a sourced script. If an output stream or an error stream was redirected in the sourced script, the respective stream remained redirected in the parent script as well. With this update, file handles are restored after execution of sourced scripts so a parent script is not affected by sourced script redirections.
BZ#644128
If a here document (heredoc - specifies a string literal in command line shells) was combined with an auto-loaded function, interference with the here document processing could occur causing output to be truncated to 8 KB. This update improves the here document processing logic and auto-loaded functions no longer have a negative side effect on here documents.
BZ#587127
As a result of a previous code optimization, the whence built-in command could enter an infinite loop when used with the -q option. Consequently, ksh consumed up to 100% of CPU and became unresponsive. With this version of ksh, the underlying code of the whence built-in command has been modified and ksh no longer hangs, when -q option is used.
BZ#573936
When performing certain operations, such as reading the user's input, ksh switches the terminal into raw mode with echo disabled. Normally, the terminal is restored with the previous settings after the operation has been finished. This did not work in the previous ksh version if the user's locale was set to use multibyte encoding (for example UTF-8). With such a locale, ksh failed to restore the terminal settings if it timed out while executing the read built-in command. Subsequently, the terminal did not echo any characters until it was reset. This updates applies a patch ensuring that the terminal is restored properly after timeout and user's input is now echoed as expected.
BZ#691850
The kill built-in command did not properly handle errors when it was given an extremely large value as the PID parameter. The kill command then internally reported the code -1, which was interpreted by ksh as the -1 option and ksh thus killed all user processes. This update corrects handling of PID conversion errors so that ksh can no longer misinterpret the kill command return values. The command now, under these circumstances, fails with an error as expected.

Enhancements

BZ#574867
The ksh built-in ulimit command now provides the ability to read and set the RLIMIT_RTPRIO and RLIMIT_NICE resource limiters.
All users of ksh are advised to upgrade to this updated package, which fixes these bugs and adds this enhancement.